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

Commit 936343d4 by Ricardo Lopes

Fixed ENUM creation

1 parent 768c4400
Showing with 4 additions and 4 deletions
......@@ -83,7 +83,7 @@ module.exports = (function() {
if (typeof attribute.defaultValue === "function" && (
attribute.defaultValue === DataTypes.NOW ||
attribute.defaultValue === DataTypes.UUIDV4 ||
attribute.defaultValue === DataTypes.UUIDV4
attribute.defaultValue === DataTypes.UUIDV4
)) {
attribute.defaultValue = new attribute.defaultValue();
}
......@@ -114,7 +114,7 @@ module.exports = (function() {
for (i = 0; i < keyLen; i++) {
if (attributes[keys[i]].type instanceof DataTypes.ENUM) {
sql = self.QueryGenerator.pgListEnums(getTableName, keys[i], options);
sql = self.QueryGenerator.pgListEnums(getTableName, attributes[keys[i]].field || keys[i], options);
promises.push(self.sequelize.query(sql, null, { plain: true, raw: true, type: QueryTypes.SELECT, logging: options.logging }));
}
}
......@@ -131,7 +131,7 @@ module.exports = (function() {
if (attributes[keys[i]].type instanceof DataTypes.ENUM) {
// If the enum type doesn't exist then create it
if (!results[enumIdx]) {
sql = self.QueryGenerator.pgEnum(getTableName, keys[i], attributes[keys[i]], options);
sql = self.QueryGenerator.pgEnum(getTableName, attributes[keys[i]].field || keys[i], attributes[keys[i]], options);
promises.push(self.sequelize.query(sql, null, { raw: true, logging: options.logging }));
} else if (!!results[enumIdx] && !!daoTable) {
var enumVals = self.QueryGenerator.fromArray(results[enumIdx].enum_value)
......@@ -632,7 +632,7 @@ module.exports = (function() {
return Promise.reduce(cascades, function (memo, cascade) {
return dao[cascade]().then(function (instances) {
if (!Array.isArray(instances)) instances = [instances];
return Promise.reduce(instances, function (memo, instance) {
return instance.destroy();
}, []);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!