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

Commit 6d19ea29 by Sushant Committed by GitHub

fix(sequelize/constructor): queryInterface was initialized on first use (#8178)

1 parent fc942b08
...@@ -27,7 +27,7 @@ function addForeignKeyConstraints(newAttribute, source, target, options, key) { ...@@ -27,7 +27,7 @@ function addForeignKeyConstraints(newAttribute, source, target, options, key) {
if (primaryKeys.length === 1) { if (primaryKeys.length === 1) {
if (source._schema) { if (source._schema) {
newAttribute.references = { newAttribute.references = {
model: source.sequelize.queryInterface.QueryGenerator.addSchema({ model: source.sequelize.getQueryInterface().QueryGenerator.addSchema({
tableName: source.tableName, tableName: source.tableName,
_schema: source._schema, _schema: source._schema,
_schemaDelimiter: source._schemaDelimiter _schemaDelimiter: source._schemaDelimiter
......
...@@ -57,7 +57,7 @@ class Query extends AbstractQuery { ...@@ -57,7 +57,7 @@ class Query extends AbstractQuery {
this.sql = sql; this.sql = sql;
if (!Utils._.isEmpty(this.options.searchPath)) { if (!Utils._.isEmpty(this.options.searchPath)) {
this.sql = this.sequelize.queryInterface.QueryGenerator.setSearchPath(this.options.searchPath) + sql; this.sql = this.sequelize.getQueryInterface().QueryGenerator.setSearchPath(this.options.searchPath) + sql;
} }
const query = parameters && parameters.length const query = parameters && parameters.length
...@@ -129,7 +129,7 @@ class Query extends AbstractQuery { ...@@ -129,7 +129,7 @@ class Query extends AbstractQuery {
// Map column index in table to column name // Map column index in table to column name
const columns = _.zipObject( const columns = _.zipObject(
row.column_indexes, row.column_indexes,
this.sequelize.queryInterface.QueryGenerator.fromArray(row.column_names) this.sequelize.getQueryInterface().QueryGenerator.fromArray(row.column_names)
); );
delete row.column_indexes; delete row.column_indexes;
delete row.column_names; delete row.column_names;
...@@ -203,7 +203,7 @@ class Query extends AbstractQuery { ...@@ -203,7 +203,7 @@ class Query extends AbstractQuery {
type: row.Type.toUpperCase(), type: row.Type.toUpperCase(),
allowNull: row.Null === 'YES', allowNull: row.Null === 'YES',
defaultValue: row.Default, defaultValue: row.Default,
special: row.special ? this.sequelize.queryInterface.QueryGenerator.fromArray(row.special) : [], special: row.special ? this.sequelize.getQueryInterface().QueryGenerator.fromArray(row.special) : [],
primaryKey: row.Constraint === 'PRIMARY KEY' primaryKey: row.Constraint === 'PRIMARY KEY'
}; };
......
...@@ -224,10 +224,12 @@ class Sequelize { ...@@ -224,10 +224,12 @@ class Sequelize {
default: default:
throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.'); throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
} }
this.dialect = new Dialect(this);
this.dialect = new Dialect(this);
this.dialect.QueryGenerator.typeValidation = options.typeValidation; this.dialect.QueryGenerator.typeValidation = options.typeValidation;
this.queryInterface = new QueryInterface(this);
/** /**
* Models are stored here under the name given to `sequelize.define` * Models are stored here under the name given to `sequelize.define`
*/ */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!