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

Commit 3181396f by Sascha Depold

check if object has own property in "var in" loop

1 parent 0d639ca8
Showing with 14 additions and 10 deletions
...@@ -15,13 +15,15 @@ module.exports = (function() { ...@@ -15,13 +15,15 @@ module.exports = (function() {
, attrStr = [] , attrStr = []
for (var attr in attributes) { for (var attr in attributes) {
var dataType = attributes[attr] if (attributes.hasOwnProperty(attr)) {
var dataType = attributes[attr]
if (Utils._.includes(dataType, 'PRIMARY KEY')) {
primaryKeys.push(attr) if (Utils._.includes(dataType, 'PRIMARY KEY')) {
attrStr.push(Utils.addTicks(attr) + " " + dataType.replace(/PRIMARY KEY/, '')) primaryKeys.push(attr)
} else { attrStr.push(Utils.addTicks(attr) + " " + dataType.replace(/PRIMARY KEY/, ''))
attrStr.push(Utils.addTicks(attr) + " " + dataType) } else {
attrStr.push(Utils.addTicks(attr) + " " + dataType)
}
} }
} }
...@@ -380,10 +382,12 @@ module.exports = (function() { ...@@ -380,10 +382,12 @@ module.exports = (function() {
var fields = [] var fields = []
for (var name in factory.attributes) { for (var name in factory.attributes) {
var definition = factory.attributes[name] if (factory.attributes.hasOwnProperty(name)) {
var definition = factory.attributes[name]
if (definition && (definition.indexOf('auto_increment') > -1)) { if (definition && (definition.indexOf('auto_increment') > -1)) {
fields.push(name) fields.push(name)
}
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!