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

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