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

Commit a3155ec8 by Mick Hansen

Merge pull request #3705 from mikrofusion/master

fix showIndexQuery so appropriate indexes are returned when a schema is used
2 parents a73e3b74 d2f0641c
# Next # Next
- [BUG] fix showIndexQuery so appropriate indexes are returned when a schema is used
- [BUG] Fix addIndexQuery error when the model has a schema - [BUG] Fix addIndexQuery error when the model has a schema
# 2.1.3 # 2.1.3
......
...@@ -426,6 +426,10 @@ module.exports = (function() { ...@@ -426,6 +426,10 @@ module.exports = (function() {
}, },
showIndexesQuery: function(tableName) { showIndexesQuery: function(tableName) {
if (!Utils._.isString(tableName)) {
tableName = tableName.tableName;
}
// This is ARCANE! // This is ARCANE!
var query = 'SELECT i.relname AS name, ix.indisprimary AS primary, ix.indisunique AS unique, ix.indkey AS indkey, ' + var query = 'SELECT i.relname AS name, ix.indisprimary AS primary, ix.indisunique AS unique, ix.indkey AS indkey, ' +
'array_agg(a.attnum) as column_indexes, array_agg(a.attname) AS column_names, pg_get_indexdef(ix.indexrelid) ' + 'array_agg(a.attnum) as column_indexes, array_agg(a.attname) AS column_names, pg_get_indexdef(ix.indexrelid) ' +
......
...@@ -107,6 +107,39 @@ describe(Support.getTestDialectTeaser('QueryInterface'), function() { ...@@ -107,6 +107,39 @@ describe(Support.getTestDialectTeaser('QueryInterface'), function() {
}); });
}); });
it('works with schemas', function() {
var self = this;
return self.sequelize.dropAllSchemas({logging: log}).then(function() {
return self.sequelize.createSchema('schema', {logging: log});
}).then(function() {
return self.queryInterface.createTable('table', {
name: {
type: DataTypes.STRING
},
isAdmin: {
type: DataTypes.STRING
}
}, {
schema: 'schema'
});
}).then(function() {
return self.queryInterface.addIndex({
schema: 'schema',
tableName: 'table'
}, ['name', 'isAdmin'], {
logging: log
}, 'schema_table').then(function() {
return self.queryInterface.showIndex({
schema: 'schema',
tableName: 'table'
}, {logging: log}).then(function(indexes) {
expect(indexes.length).to.eq(1);
count = 0;
});
});
});
});
it('does not fail on reserved keywords', function() { it('does not fail on reserved keywords', function() {
return this.queryInterface.addIndex('Group', ['from']); return this.queryInterface.addIndex('Group', ['from']);
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!