不要怂,就是干,撸起袖子干!

Commit 5eaa69de by Oliver Walzer

Adds an additional check for enum value before converting it toLowerCase

Basically fixes an issue introduced with commit 2d298a3c that causes conversion of undefined toLowerCase

TypeError: Cannot call method 'toLowerCase' of undefined
    at null.<anonymous> (/path/to/project/modules/elms/node_modules/sequelize/lib/dao.js:139:127)
    at EventEmitter.emit (events.js:95:17)
    at null.<anonymous> (/path/to/project/modules/elms/node_modules/sequelize/lib/dao-validator.js:45:17)
    at Hooks.runHooks (/path/to/project/modules/elms/node_modules/sequelize/lib/hooks.js:19:15)
    at null.<anonymous> (/path/to/project/modules/elms/node_modules/sequelize/lib/dao-validator.js:39:29)
    at Hooks.runHooks (/path/to/project/modules/elms/node_modules/sequelize/lib/hooks.js:19:15)
    at null.fct (/path/to/project/modules/elms/node_modules/sequelize/lib/dao-validator.js:26:27)
    at null.<anonymous> (/path/to/project/modules/elms/node_modules/sequelize/lib/emitters/custom-event-emitter.js:25:18)
    at processImmediate [as _immediateCallback] (timers.js:330:15)
1 parent d5c66c39
Showing with 1 additions and 1 deletions
...@@ -135,7 +135,7 @@ module.exports = (function() { ...@@ -135,7 +135,7 @@ module.exports = (function() {
, ciCollation = !!self.daoFactory.options.collate && self.daoFactory.options.collate.match(/_ci$/i) , ciCollation = !!self.daoFactory.options.collate && self.daoFactory.options.collate.match(/_ci$/i)
// Unfortunately for MySQL CI collation we need to map/lowercase values again // Unfortunately for MySQL CI collation we need to map/lowercase values again
if (isEnum && isMySQL && ciCollation && (attrName in values)) { if (isEnum && isMySQL && ciCollation && (attrName in values) && values[attrName]) {
var scopeIndex = (definition.values || []).map(function(d) { return d.toLowerCase() }).indexOf(values[attrName].toLowerCase()) var scopeIndex = (definition.values || []).map(function(d) { return d.toLowerCase() }).indexOf(values[attrName].toLowerCase())
valueOutOfScope = scopeIndex === -1 valueOutOfScope = scopeIndex === -1
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!