template and back
This commit is contained in:
commit
07ef7e9b8f
3773 files changed
+422508
No files matched your search
+241
@@ -0,0 +1,241 @@
|
||||
"use strict";
|
||||
const { Pool, TimeoutError } = require("sequelize-pool");
|
||||
const _ = require("lodash");
|
||||
const semver = require("semver");
|
||||
const errors = require("../../errors");
|
||||
const { logger } = require("../../utils/logger");
|
||||
const deprecations = require("../../utils/deprecations");
|
||||
const debug = logger.debugContext("pool");
|
||||
class ConnectionManager {
|
||||
constructor(dialect, sequelize) {
|
||||
const config = _.cloneDeep(sequelize.config);
|
||||
this.sequelize = sequelize;
|
||||
this.config = config;
|
||||
this.dialect = dialect;
|
||||
this.versionPromise = null;
|
||||
this.dialectName = this.sequelize.options.dialect;
|
||||
if (config.pool === false) {
|
||||
throw new Error("Support for pool:false was removed in v4.0");
|
||||
}
|
||||
config.pool = _.defaults(config.pool || {}, {
|
||||
max: 5,
|
||||
min: 0,
|
||||
idle: 1e4,
|
||||
acquire: 6e4,
|
||||
evict: 1e3,
|
||||
validate: this._validate.bind(this)
|
||||
});
|
||||
this.initPools();
|
||||
}
|
||||
refreshTypeParser(dataTypes) {
|
||||
_.each(dataTypes, (dataType) => {
|
||||
if (Object.prototype.hasOwnProperty.call(dataType, "parse")) {
|
||||
if (dataType.types[this.dialectName]) {
|
||||
this._refreshTypeParser(dataType);
|
||||
} else {
|
||||
throw new Error(`Parse function not supported for type ${dataType.key} in dialect ${this.dialectName}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
_loadDialectModule(moduleName) {
|
||||
try {
|
||||
if (this.sequelize.config.dialectModulePath) {
|
||||
return require(this.sequelize.config.dialectModulePath);
|
||||
}
|
||||
if (this.sequelize.config.dialectModule) {
|
||||
return this.sequelize.config.dialectModule;
|
||||
}
|
||||
return require(moduleName);
|
||||
} catch (err) {
|
||||
if (err.code === "MODULE_NOT_FOUND") {
|
||||
if (this.sequelize.config.dialectModulePath) {
|
||||
throw new Error(`Unable to find dialect at ${this.sequelize.config.dialectModulePath}`);
|
||||
}
|
||||
throw new Error(`Please install ${moduleName} package manually`);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
async _onProcessExit() {
|
||||
if (!this.pool) {
|
||||
return;
|
||||
}
|
||||
await this.pool.drain();
|
||||
debug("connection drain due to process exit");
|
||||
return await this.pool.destroyAllNow();
|
||||
}
|
||||
async close() {
|
||||
this.getConnection = async function getConnection() {
|
||||
throw new Error("ConnectionManager.getConnection was called after the connection manager was closed!");
|
||||
};
|
||||
return await this._onProcessExit();
|
||||
}
|
||||
initPools() {
|
||||
const config = this.config;
|
||||
if (!config.replication) {
|
||||
this.pool = new Pool({
|
||||
name: "sequelize",
|
||||
create: () => this._connect(config),
|
||||
destroy: async (connection) => {
|
||||
const result = await this._disconnect(connection);
|
||||
debug("connection destroy");
|
||||
return result;
|
||||
},
|
||||
validate: config.pool.validate,
|
||||
max: config.pool.max,
|
||||
min: config.pool.min,
|
||||
acquireTimeoutMillis: config.pool.acquire,
|
||||
idleTimeoutMillis: config.pool.idle,
|
||||
reapIntervalMillis: config.pool.evict,
|
||||
maxUses: config.pool.maxUses
|
||||
});
|
||||
debug(`pool created with max/min: ${config.pool.max}/${config.pool.min}, no replication`);
|
||||
return;
|
||||
}
|
||||
if (!Array.isArray(config.replication.read)) {
|
||||
config.replication.read = [config.replication.read];
|
||||
}
|
||||
config.replication.write = _.defaults(config.replication.write, _.omit(config, "replication"));
|
||||
config.replication.read = config.replication.read.map((readConfig) => _.defaults(readConfig, _.omit(this.config, "replication")));
|
||||
let reads = 0;
|
||||
this.pool = {
|
||||
release: (client) => {
|
||||
if (client.queryType === "read") {
|
||||
this.pool.read.release(client);
|
||||
} else {
|
||||
this.pool.write.release(client);
|
||||
}
|
||||
},
|
||||
acquire: (queryType, useMaster) => {
|
||||
useMaster = useMaster === void 0 ? false : useMaster;
|
||||
if (queryType === "SELECT" && !useMaster) {
|
||||
return this.pool.read.acquire();
|
||||
}
|
||||
return this.pool.write.acquire();
|
||||
},
|
||||
destroy: (connection) => {
|
||||
this.pool[connection.queryType].destroy(connection);
|
||||
debug("connection destroy");
|
||||
},
|
||||
destroyAllNow: async () => {
|
||||
await Promise.all([
|
||||
this.pool.read.destroyAllNow(),
|
||||
this.pool.write.destroyAllNow()
|
||||
]);
|
||||
debug("all connections destroyed");
|
||||
},
|
||||
drain: async () => Promise.all([
|
||||
this.pool.write.drain(),
|
||||
this.pool.read.drain()
|
||||
]),
|
||||
read: new Pool({
|
||||
name: "sequelize:read",
|
||||
create: async () => {
|
||||
const nextRead = reads++ % config.replication.read.length;
|
||||
const connection = await this._connect(config.replication.read[nextRead]);
|
||||
connection.queryType = "read";
|
||||
return connection;
|
||||
},
|
||||
destroy: (connection) => this._disconnect(connection),
|
||||
validate: config.pool.validate,
|
||||
max: config.pool.max,
|
||||
min: config.pool.min,
|
||||
acquireTimeoutMillis: config.pool.acquire,
|
||||
idleTimeoutMillis: config.pool.idle,
|
||||
reapIntervalMillis: config.pool.evict,
|
||||
maxUses: config.pool.maxUses
|
||||
}),
|
||||
write: new Pool({
|
||||
name: "sequelize:write",
|
||||
create: async () => {
|
||||
const connection = await this._connect(config.replication.write);
|
||||
connection.queryType = "write";
|
||||
return connection;
|
||||
},
|
||||
destroy: (connection) => this._disconnect(connection),
|
||||
validate: config.pool.validate,
|
||||
max: config.pool.max,
|
||||
min: config.pool.min,
|
||||
acquireTimeoutMillis: config.pool.acquire,
|
||||
idleTimeoutMillis: config.pool.idle,
|
||||
reapIntervalMillis: config.pool.evict,
|
||||
maxUses: config.pool.maxUses
|
||||
})
|
||||
};
|
||||
debug(`pool created with max/min: ${config.pool.max}/${config.pool.min}, with replication`);
|
||||
}
|
||||
async getConnection(options) {
|
||||
options = options || {};
|
||||
if (this.sequelize.options.databaseVersion === 0) {
|
||||
if (!this.versionPromise) {
|
||||
this.versionPromise = (async () => {
|
||||
try {
|
||||
const connection = await this._connect(this.config.replication.write || this.config);
|
||||
const _options = {};
|
||||
_options.transaction = { connection };
|
||||
_options.logging = () => {
|
||||
};
|
||||
_options.logging.__testLoggingFn = true;
|
||||
if (this.sequelize.options.databaseVersion === 0) {
|
||||
const version = await this.sequelize.databaseVersion(_options);
|
||||
const parsedVersion = _.get(semver.coerce(version), "version") || version;
|
||||
this.sequelize.options.databaseVersion = semver.valid(parsedVersion) ? parsedVersion : this.dialect.defaultVersion;
|
||||
}
|
||||
if (semver.lt(this.sequelize.options.databaseVersion, this.dialect.defaultVersion)) {
|
||||
deprecations.unsupportedEngine();
|
||||
debug(`Unsupported database engine version ${this.sequelize.options.databaseVersion}`);
|
||||
}
|
||||
this.versionPromise = null;
|
||||
return await this._disconnect(connection);
|
||||
} catch (err) {
|
||||
this.versionPromise = null;
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
}
|
||||
await this.versionPromise;
|
||||
}
|
||||
let result;
|
||||
try {
|
||||
await this.sequelize.runHooks("beforePoolAcquire", options);
|
||||
result = await this.pool.acquire(options.type, options.useMaster);
|
||||
await this.sequelize.runHooks("afterPoolAcquire", result, options);
|
||||
} catch (error) {
|
||||
if (error instanceof TimeoutError)
|
||||
throw new errors.ConnectionAcquireTimeoutError(error);
|
||||
throw error;
|
||||
}
|
||||
debug("connection acquired");
|
||||
return result;
|
||||
}
|
||||
releaseConnection(connection) {
|
||||
this.pool.release(connection);
|
||||
debug("connection released");
|
||||
}
|
||||
async destroyConnection(connection) {
|
||||
await this.pool.destroy(connection);
|
||||
debug(`connection ${connection.uuid} destroyed`);
|
||||
}
|
||||
async _connect(config) {
|
||||
await this.sequelize.runHooks("beforeConnect", config);
|
||||
const connection = await this.dialect.connectionManager.connect(config);
|
||||
await this.sequelize.runHooks("afterConnect", connection, config);
|
||||
return connection;
|
||||
}
|
||||
async _disconnect(connection) {
|
||||
await this.sequelize.runHooks("beforeDisconnect", connection);
|
||||
await this.dialect.connectionManager.disconnect(connection);
|
||||
return this.sequelize.runHooks("afterDisconnect", connection);
|
||||
}
|
||||
_validate(connection) {
|
||||
if (!this.dialect.connectionManager.validate) {
|
||||
return true;
|
||||
}
|
||||
return this.dialect.connectionManager.validate(connection);
|
||||
}
|
||||
}
|
||||
module.exports = ConnectionManager;
|
||||
module.exports.ConnectionManager = ConnectionManager;
|
||||
module.exports.default = ConnectionManager;
|
||||
//# sourceMappingURL=connection-manager.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../src/dialects/abstract/connection-manager.js"],
|
||||
"sourcesContent": ["'use strict';\n\nconst { Pool, TimeoutError } = require('sequelize-pool');\nconst _ = require('lodash');\nconst semver = require('semver');\nconst errors = require('../../errors');\nconst { logger } = require('../../utils/logger');\nconst deprecations = require('../../utils/deprecations');\nconst debug = logger.debugContext('pool');\n\n/**\n * Abstract Connection Manager\n *\n * Connection manager which handles pooling & replication.\n * Uses sequelize-pool for pooling\n *\n * @private\n */\nclass ConnectionManager {\n constructor(dialect, sequelize) {\n const config = _.cloneDeep(sequelize.config);\n\n this.sequelize = sequelize;\n this.config = config;\n this.dialect = dialect;\n this.versionPromise = null;\n this.dialectName = this.sequelize.options.dialect;\n\n if (config.pool === false) {\n throw new Error('Support for pool:false was removed in v4.0');\n }\n\n config.pool = _.defaults(config.pool || {}, {\n max: 5,\n min: 0,\n idle: 10000,\n acquire: 60000,\n evict: 1000,\n validate: this._validate.bind(this)\n });\n\n this.initPools();\n }\n\n refreshTypeParser(dataTypes) {\n _.each(dataTypes, dataType => {\n if (Object.prototype.hasOwnProperty.call(dataType, 'parse')) {\n if (dataType.types[this.dialectName]) {\n this._refreshTypeParser(dataType);\n } else {\n throw new Error(`Parse function not supported for type ${dataType.key} in dialect ${this.dialectName}`);\n }\n }\n });\n }\n\n /**\n * Try to load dialect module from various configured options.\n * Priority goes like dialectModulePath > dialectModule > require(default)\n *\n * @param {string} moduleName Name of dialect module to lookup\n *\n * @private\n * @returns {object}\n */\n _loadDialectModule(moduleName) {\n try {\n if (this.sequelize.config.dialectModulePath) {\n return require(this.sequelize.config.dialectModulePath);\n }\n if (this.sequelize.config.dialectModule) {\n return this.sequelize.config.dialectModule;\n }\n return require(moduleName);\n\n } catch (err) {\n if (err.code === 'MODULE_NOT_FOUND') {\n if (this.sequelize.config.dialectModulePath) {\n throw new Error(`Unable to find dialect at ${this.sequelize.config.dialectModulePath}`);\n }\n throw new Error(`Please install ${moduleName} package manually`);\n }\n\n throw err;\n }\n }\n\n /**\n * Handler which executes on process exit or connection manager shutdown\n *\n * @private\n * @returns {Promise}\n */\n async _onProcessExit() {\n if (!this.pool) {\n return;\n }\n\n await this.pool.drain();\n debug('connection drain due to process exit');\n\n return await this.pool.destroyAllNow();\n }\n\n /**\n * Drain the pool and close it permanently\n *\n * @returns {Promise}\n */\n async close() {\n // Mark close of pool\n this.getConnection = async function getConnection() {\n throw new Error('ConnectionManager.getConnection was called after the connection manager was closed!');\n };\n\n return await this._onProcessExit();\n }\n\n /**\n * Initialize connection pool. By default pool autostart is set to false, so no connection will be\n * be created unless `pool.acquire` is called.\n */\n initPools() {\n const config = this.config;\n\n if (!config.replication) {\n this.pool = new Pool({\n name: 'sequelize',\n create: () => this._connect(config),\n destroy: async connection => {\n const result = await this._disconnect(connection);\n debug('connection destroy');\n return result;\n },\n validate: config.pool.validate,\n max: config.pool.max,\n min: config.pool.min,\n acquireTimeoutMillis: config.pool.acquire,\n idleTimeoutMillis: config.pool.idle,\n reapIntervalMillis: config.pool.evict,\n maxUses: config.pool.maxUses\n });\n\n debug(`pool created with max/min: ${config.pool.max}/${config.pool.min}, no replication`);\n\n return;\n }\n\n if (!Array.isArray(config.replication.read)) {\n config.replication.read = [config.replication.read];\n }\n\n // Map main connection config\n config.replication.write = _.defaults(config.replication.write, _.omit(config, 'replication'));\n\n // Apply defaults to each read config\n config.replication.read = config.replication.read.map(readConfig =>\n _.defaults(readConfig, _.omit(this.config, 'replication'))\n );\n\n // custom pooling for replication (original author @janmeier)\n let reads = 0;\n this.pool = {\n release: client => {\n if (client.queryType === 'read') {\n this.pool.read.release(client);\n } else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A;AAAA;AAIZ,YAAM,KAAK;AAAA;AAGb,QAAI;AAEJ,QAAI;AAEF,YAAM,KAAK,UAAU,SAAS,qBAAqB;AAEnD,eAAS,MAAM,KAAK,KAAK,QAAQ,QAAQ,MAAM,QAAQ;AAEvD,YAAM,KAAK,UAAU,SAAS,oBAAoB,QAAQ;AAAA,aAEnD,OAAP;AACA,UAAI,iBAAiB;AAAc,cAAM,IAAI,OAAO,8BAA8B;AAClF,YAAM;AAAA;AAGR,UAAM;AAEN,WAAO;AAAA;AAAA,EAQT,kBAAkB,YAAY;AAC5B,SAAK,KAAK,QAAQ;AAClB,UAAM;AAAA;AAAA,QAQF,kBAAkB,YAAY;AAClC,UAAM,KAAK,KAAK,QAAQ;AACxB,UAAM,cAAc,WAAW;AAAA;AAAA,QAU3B,SAAS,QAAQ;AACrB,UAAM,KAAK,UAAU,SAAS,iBAAiB;AAC/C,UAAM,aAAa,MAAM,KAAK,QAAQ,kBAAkB,QAAQ;AAChE,UAAM,KAAK,UAAU,SAAS,gBAAgB,YAAY;AAC1D,WAAO;AAAA;AAAA,QAUH,YAAY,YAAY;AAC5B,UAAM,KAAK,UAAU,SAAS,oBAAoB;AAClD,UAAM,KAAK,QAAQ,kBAAkB,WAAW;AAChD,WAAO,KAAK,UAAU,SAAS,mBAAmB;AAAA;AAAA,EAUpD,UAAU,YAAY;AACpB,QAAI,CAAC,KAAK,QAAQ,kBAAkB,UAAU;AAC5C,aAAO;AAAA;AAGT,WAAO,KAAK,QAAQ,kBAAkB,SAAS;AAAA;AAAA;AAInD,OAAO,UAAU;AACjB,OAAO,QAAQ,oBAAoB;AACnC,OAAO,QAAQ,UAAU;",
|
||||
"names": []
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
class AbstractDialect {
|
||||
canBackslashEscape() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
AbstractDialect.prototype.supports = {
|
||||
"DEFAULT": true,
|
||||
"DEFAULT VALUES": false,
|
||||
"VALUES ()": false,
|
||||
"LIMIT ON UPDATE": false,
|
||||
"ON DUPLICATE KEY": true,
|
||||
"ORDER NULLS": false,
|
||||
"UNION": true,
|
||||
"UNION ALL": true,
|
||||
"RIGHT JOIN": true,
|
||||
returnValues: false,
|
||||
autoIncrement: {
|
||||
identityInsert: false,
|
||||
defaultValue: true,
|
||||
update: true
|
||||
},
|
||||
bulkDefault: false,
|
||||
schemas: false,
|
||||
transactions: true,
|
||||
settingIsolationLevelDuringTransaction: true,
|
||||
transactionOptions: {
|
||||
type: false
|
||||
},
|
||||
migrations: true,
|
||||
upserts: true,
|
||||
inserts: {
|
||||
ignoreDuplicates: "",
|
||||
updateOnDuplicate: false,
|
||||
onConflictDoNothing: "",
|
||||
onConflictWhere: false,
|
||||
conflictFields: false
|
||||
},
|
||||
constraints: {
|
||||
restrict: true,
|
||||
addConstraint: true,
|
||||
dropConstraint: true,
|
||||
unique: true,
|
||||
default: false,
|
||||
check: true,
|
||||
foreignKey: true,
|
||||
primaryKey: true
|
||||
},
|
||||
index: {
|
||||
collate: true,
|
||||
length: false,
|
||||
parser: false,
|
||||
concurrently: false,
|
||||
type: false,
|
||||
using: true,
|
||||
functionBased: false,
|
||||
operator: false
|
||||
},
|
||||
groupedLimit: true,
|
||||
indexViaAlter: false,
|
||||
JSON: false,
|
||||
deferrableConstraints: false,
|
||||
escapeStringConstants: false
|
||||
};
|
||||
module.exports = AbstractDialect;
|
||||
module.exports.AbstractDialect = AbstractDialect;
|
||||
module.exports.default = AbstractDialect;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../src/dialects/abstract/index.js"],
|
||||
"sourcesContent": ["'use strict';\n\nclass AbstractDialect {\n /**\n * Whether this dialect can use \\ in strings to escape string delimiters.\n *\n * @returns {boolean}\n */\n canBackslashEscape() {\n return false;\n }\n}\n\nAbstractDialect.prototype.supports = {\n 'DEFAULT': true,\n 'DEFAULT VALUES': false,\n 'VALUES ()': false,\n 'LIMIT ON UPDATE': false,\n 'ON DUPLICATE KEY': true,\n 'ORDER NULLS': false,\n 'UNION': true,\n 'UNION ALL': true,\n 'RIGHT JOIN': true,\n\n /* does the dialect support returning values for inserted/updated fields */\n returnValues: false,\n\n /* features specific to autoIncrement values */\n autoIncrement: {\n /* does the dialect require modification of insert queries when inserting auto increment fields */\n identityInsert: false,\n\n /* does the dialect support inserting default/null values for autoincrement fields */\n defaultValue: true,\n\n /* does the dialect support updating autoincrement fields */\n update: true\n },\n /* Do we need to say DEFAULT for bulk insert */\n bulkDefault: false,\n schemas: false,\n transactions: true,\n settingIsolationLevelDuringTransaction: true,\n transactionOptions: {\n type: false\n },\n migrations: true,\n upserts: true,\n inserts: {\n ignoreDuplicates: '', /* dialect specific words for INSERT IGNORE or DO NOTHING */\n updateOnDuplicate: false, /* whether dialect supports ON DUPLICATE KEY UPDATE */\n onConflictDoNothing: '', /* dialect specific words for ON CONFLICT DO NOTHING */\n onConflictWhere: false, /* whether dialect supports ON CONFLICT WHERE */\n conflictFields: false /* whether the dialect supports specifying conflict fields or not */\n },\n constraints: {\n restrict: true,\n addConstraint: true,\n dropConstraint: true,\n unique: true,\n default: false,\n check: true,\n foreignKey: true,\n primaryKey: true\n },\n index: {\n collate: true,\n length: false,\n parser: false,\n concurrently: false,\n type: false,\n using: true,\n functionBased: false,\n operator: false\n },\n groupedLimit: true,\n indexViaAlter: false,\n JSON: false,\n /**\n * This dialect supports marking a column's constraints as deferrable.\n * e.g. 'DEFERRABLE' and 'INITIALLY DEFERRED'\n */\n deferrableConstraints: false,\n escapeStringConstants: false\n};\n\nmodule.exports = AbstractDialect;\nmodule.exports.AbstractDialect = AbstractDialect;\nmodule.exports.default = AbstractDialect;\n"],
|
||||
"mappings": ";AAEA,sBAAsB;AAAA,EAMpB,qBAAqB;AACnB,WAAO;AAAA;AAAA;AAIX,gBAAgB,UAAU,WAAW;AAAA,EACnC,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAAA,EAGd,cAAc;AAAA,EAGd,eAAe;AAAA,IAEb,gBAAgB;AAAA,IAGhB,cAAc;AAAA,IAGd,QAAQ;AAAA;AAAA,EAGV,aAAa;AAAA,EACb,SAAS;AAAA,EACT,cAAc;AAAA,EACd,wCAAwC;AAAA,EACxC,oBAAoB;AAAA,IAClB,MAAM;AAAA;AAAA,EAER,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,IACP,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,gBAAgB;AAAA;AAAA,EAElB,aAAa;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,YAAY;AAAA;AAAA,EAEd,OAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,IACP,eAAe;AAAA,IACf,UAAU;AAAA;AAAA,EAEZ,cAAc;AAAA,EACd,eAAe;AAAA,EACf,MAAM;AAAA,EAKN,uBAAuB;AAAA,EACvB,uBAAuB;AAAA;AAGzB,OAAO,UAAU;AACjB,OAAO,QAAQ,kBAAkB;AACjC,OAAO,QAAQ,UAAU;",
|
||||
"names": []
|
||||
}
|
||||
+2143
File diff suppressed because it is too large.
Load diff
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../src/dialects/abstract/query-generator.js"],
|
||||
"sourcesContent": ["'use strict';\n\nconst util = require('util');\nconst _ = require('lodash');\nconst uuidv4 = require('uuid').v4;\n\nconst Utils = require('../../utils');\nconst deprecations = require('../../utils/deprecations');\nconst SqlString = require('../../sql-string');\nconst DataTypes = require('../../data-types');\nconst Model = require('../../model');\nconst Association = require('../../associations/base');\nconst BelongsTo = require('../../associations/belongs-to');\nconst BelongsToMany = require('../../associations/belongs-to-many');\nconst HasMany = require('../../associations/has-many');\nconst Op = require('../../operators');\nconst sequelizeError = require('../../errors');\nconst IndexHints = require('../../index-hints');\n\n\n/**\n * Abstract Query Generator\n *\n * @private\n */\nclass QueryGenerator {\n constructor(options) {\n if (!options.sequelize) throw new Error('QueryGenerator initialized without options.sequelize');\n if (!options._dialect) throw new Error('QueryGenerator initialized without options._dialect');\n\n this.sequelize = options.sequelize;\n this.options = options.sequelize.options;\n\n // dialect name\n this.dialect = options._dialect.name;\n this._dialect = options._dialect;\n\n // wrap quoteIdentifier with common logic\n this._initQuoteIdentifier();\n }\n\n extractTableDetails(tableName, options) {\n options = options || {};\n tableName = tableName || {};\n return {\n schema: tableName.schema || options.schema || this.options.schema || 'public',\n tableName: _.isPlainObject(tableName) ? tableName.tableName : tableName,\n delimiter: tableName.delimiter || options.delimiter || '.'\n };\n }\n\n addSchema(param) {\n if (!param._schema) return param.tableName || param;\n const self = this;\n return {\n tableName: param.tableName || param,\n table: param.tableName || param,\n name: param.name || param,\n schema: param._schema,\n delimiter: param._schemaDelimiter || '.',\n toString() {\n return self.quoteTable(this);\n }\n };\n }\n\n dropSchema(tableName, options) {\n return this.dropTableQuery(tableName, options);\n }\n\n describeTableQuery(tableName, schema, schemaDelimiter) {\n const table = this.quoteTable(\n this.addSchema({\n tableName,\n _schema: schema,\n _schemaDelimiter: schemaDelimiter\n })\n );\n\n return `DESCRIBE ${table};`;\n }\n\n dropTableQuery(tableName) {\n return `DROP TABLE IF EXISTS ${this.quoteTable(tableName)};`;\n }\n\n renameTableQuery(before, after) {\n return `ALTER TABLE ${this.quoteTable(before)} RENAME TO ${this.quoteTable(after)};`;\n }\n\n /**\n * Helper method for populating the returning into bind information\n * that is needed by some dialects (currently Oracle)\n *\n * @private\n */\n populateInsertQueryReturnIntoBinds() {\n // noop by default\n }\n\n /**\n * Returns an insert into command\n *\n * @param {string} table\n * @param {object} valueHash attribute value pairs\n * @param {object} modelAttributes\n * @param {object} [options]\n *\n * @private\n */\n insertQuery(table, valueHash, modelAttributes, options) {\n options = options || {};\n _.defaults(options, this.options);\n\n const modelAttributeMap = {};\n const bind = options.bind || [];\n const fields = [];\n const returningModelAttributes = [];\n const returnTypes = [];\n const values = [];\n const quotedTable = this.quoteTable(table);\n const bindParam = options.bindParam === undefined ? this.bindParam(bind) : options.bindParam;\n const returnAttributes = [];\n let query;\n let valueQuery = '';\n let emptyQuery = '';\n let outputFragment = '';\n let returningFragment = '';\n let identityWrapperRequired = false;\n let tmpTable = ''; //tmpTable declaration for trigger\n\n if (modelAttributes) {\n _.each(modelAttributes, (attribute, key) => {\n modelAttributeMap[key] = attribute;\n if (attribute.field) {\n modelAttributeMap[attribute.field] = attribute;\n }\n });\n }\n\n if (this._dialect.supports['DEFAULT VALUES']) {\n emptyQuery += ' DEFAULT VALUES';\n } else if (this._dialect.supports['VALUES ()']) {\n emptyQuery += ' VALUES ()';\n }\n\n if ((this._dialect.supports.returnValues || this._dialect.supports.returnIntoValues) && options.returning) {\n const returnValues = this.generateReturnValues(modelAttributes, options);\n\n returningModelAttributes.push(...returnValues.returnFields);\n // Storing the returnTypes for dialects that need to have returning into bind information for outbinds\n if (this._dialect.supports.returnIntoValues) {\n returnTypes.push(...returnValues.returnTypes);\n }\n returningFragment = returnValues.returningFragment;\n tmpTable = returnValues.tmpTable || '';\n outputFragmentLine truncated
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,OAAO,QAAQ;AACrB,MAAM,IAAI,QAAQ;AAClB,MAAM,SAAS,QAAQ,QAAQ;AAE/B,MAAM,QAAQ,QAAQ;AACtB,MAAM,eAAe,QAAQ;AAC7B,MAAM,YAAY,QAAQ;AAC1B,MAAM,YAAY,QAAQ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AkB,aAAa,UAAU,uBAAuB,aAAa,sBAAsB;AAClO,iBAAa,GAAG,iBAAiB,aAAa,yBAAyB,cAAc,aAAa,SAAS,uBAAuB,aAAa,sBAAsB;AAIrK,QAAI,KAAK,SAAS,SAAS,aAAa,QAAQ,WAAW;AACzD,YAAM,eAAe;AAErB,UAAI,yBAAyB,WAAW,GAAG;AACzC,iCAAyB,KAAK;AAAA;AAGhC,YAAM,YAAY,SAAS,SAAS,QAAQ,MAAM;AAClD,YAAM,cAAc,8BAA8B,yBAAyB,KAAK;AAEhF,cAAQ,YAAY;AACpB,mBAAa,4DAA4D,uEAAuE,mBAAmB,mDAAmD,QAAQ,iBAAiB,+BAA+B,eAAe;AAAA,WACxR;AACL,oBAAc;AACd,oBAAc;AAAA;AAGhB,QAAI,KAAK,SAAS,SAAS,oBAAoB,QAAQ,WAAW;AAEhE,WAAK,mCAAmC,0BAA0B,aAAa,KAAK,QAAQ,kBAAkB;AAAA;AAGhH,YAAQ,GAAG,aAAa,WAAW,SAAS,aAAa,aAAa,iBAAiB,KAAK;AAC5F,QAAI,KAAK,SAAS,SAAS,YAAY;AACrC,cAAQ,6BAA8B,aAAa,WAAW,SAAS,aAAa;AAAA;AAEtF,QAAI,2BAA2B,KAAK,SAAS,SAAS,cAAc,gBAAgB;AAClF,cAAQ,uBAAuB,mBAAmB,6BAA6B;AAAA;AAILine truncated
|
||||
"names": []
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
const _ = require("lodash");
|
||||
const Op = require("../../../operators");
|
||||
const Utils = require("../../../utils");
|
||||
const OperatorHelpers = {
|
||||
OperatorMap: {
|
||||
[Op.eq]: "=",
|
||||
[Op.ne]: "!=",
|
||||
[Op.gte]: ">=",
|
||||
[Op.gt]: ">",
|
||||
[Op.lte]: "<=",
|
||||
[Op.lt]: "<",
|
||||
[Op.not]: "IS NOT",
|
||||
[Op.is]: "IS",
|
||||
[Op.in]: "IN",
|
||||
[Op.notIn]: "NOT IN",
|
||||
[Op.like]: "LIKE",
|
||||
[Op.notLike]: "NOT LIKE",
|
||||
[Op.iLike]: "ILIKE",
|
||||
[Op.notILike]: "NOT ILIKE",
|
||||
[Op.startsWith]: "LIKE",
|
||||
[Op.endsWith]: "LIKE",
|
||||
[Op.substring]: "LIKE",
|
||||
[Op.regexp]: "~",
|
||||
[Op.notRegexp]: "!~",
|
||||
[Op.iRegexp]: "~*",
|
||||
[Op.notIRegexp]: "!~*",
|
||||
[Op.between]: "BETWEEN",
|
||||
[Op.notBetween]: "NOT BETWEEN",
|
||||
[Op.overlap]: "&&",
|
||||
[Op.contains]: "@>",
|
||||
[Op.contained]: "<@",
|
||||
[Op.adjacent]: "-|-",
|
||||
[Op.strictLeft]: "<<",
|
||||
[Op.strictRight]: ">>",
|
||||
[Op.noExtendRight]: "&<",
|
||||
[Op.noExtendLeft]: "&>",
|
||||
[Op.any]: "ANY",
|
||||
[Op.all]: "ALL",
|
||||
[Op.and]: " AND ",
|
||||
[Op.or]: " OR ",
|
||||
[Op.col]: "COL",
|
||||
[Op.placeholder]: "$$PLACEHOLDER$$",
|
||||
[Op.match]: "@@"
|
||||
},
|
||||
OperatorsAliasMap: {},
|
||||
setOperatorsAliases(aliases) {
|
||||
if (!aliases || _.isEmpty(aliases)) {
|
||||
this.OperatorsAliasMap = false;
|
||||
} else {
|
||||
this.OperatorsAliasMap = __spreadValues({}, aliases);
|
||||
}
|
||||
},
|
||||
_replaceAliases(orig) {
|
||||
const obj = {};
|
||||
if (!this.OperatorsAliasMap) {
|
||||
return orig;
|
||||
}
|
||||
Utils.getOperators(orig).forEach((op) => {
|
||||
const item = orig[op];
|
||||
if (_.isPlainObject(item)) {
|
||||
obj[op] = this._replaceAliases(item);
|
||||
} else {
|
||||
obj[op] = item;
|
||||
}
|
||||
});
|
||||
_.forOwn(orig, (item, prop) => {
|
||||
prop = this.OperatorsAliasMap[prop] || prop;
|
||||
if (_.isPlainObject(item)) {
|
||||
item = this._replaceAliases(item);
|
||||
}
|
||||
obj[prop] = item;
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
module.exports = OperatorHelpers;
|
||||
//# sourceMappingURL=operators.js.map
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../../src/dialects/abstract/query-generator/operators.js"],
|
||||
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\nconst Op = require('../../../operators');\nconst Utils = require('../../../utils');\n\nconst OperatorHelpers = {\n OperatorMap: {\n [Op.eq]: '=',\n [Op.ne]: '!=',\n [Op.gte]: '>=',\n [Op.gt]: '>',\n [Op.lte]: '<=',\n [Op.lt]: '<',\n [Op.not]: 'IS NOT',\n [Op.is]: 'IS',\n [Op.in]: 'IN',\n [Op.notIn]: 'NOT IN',\n [Op.like]: 'LIKE',\n [Op.notLike]: 'NOT LIKE',\n [Op.iLike]: 'ILIKE',\n [Op.notILike]: 'NOT ILIKE',\n [Op.startsWith]: 'LIKE',\n [Op.endsWith]: 'LIKE',\n [Op.substring]: 'LIKE',\n [Op.regexp]: '~',\n [Op.notRegexp]: '!~',\n [Op.iRegexp]: '~*',\n [Op.notIRegexp]: '!~*',\n [Op.between]: 'BETWEEN',\n [Op.notBetween]: 'NOT BETWEEN',\n [Op.overlap]: '&&',\n [Op.contains]: '@>',\n [Op.contained]: '<@',\n [Op.adjacent]: '-|-',\n [Op.strictLeft]: '<<',\n [Op.strictRight]: '>>',\n [Op.noExtendRight]: '&<',\n [Op.noExtendLeft]: '&>',\n [Op.any]: 'ANY',\n [Op.all]: 'ALL',\n [Op.and]: ' AND ',\n [Op.or]: ' OR ',\n [Op.col]: 'COL',\n [Op.placeholder]: '$$PLACEHOLDER$$',\n [Op.match]: '@@'\n },\n\n OperatorsAliasMap: {},\n\n setOperatorsAliases(aliases) {\n if (!aliases || _.isEmpty(aliases)) {\n this.OperatorsAliasMap = false;\n } else {\n this.OperatorsAliasMap = { ...aliases };\n }\n },\n\n _replaceAliases(orig) {\n const obj = {};\n if (!this.OperatorsAliasMap) {\n return orig;\n }\n\n Utils.getOperators(orig).forEach(op => {\n const item = orig[op];\n if (_.isPlainObject(item)) {\n obj[op] = this._replaceAliases(item);\n } else {\n obj[op] = item;\n }\n });\n\n _.forOwn(orig, (item, prop) => {\n prop = this.OperatorsAliasMap[prop] || prop;\n if (_.isPlainObject(item)) {\n item = this._replaceAliases(item);\n }\n obj[prop] = item;\n });\n return obj;\n }\n};\n\nmodule.exports = OperatorHelpers;\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,QAAQ;AAClB,MAAM,KAAK,QAAQ;AACnB,MAAM,QAAQ,QAAQ;AAEtB,MAAM,kBAAkB;AAAA,EACtB,aAAa;AAAA,KACV,GAAG,KAAK;AAAA,KACR,GAAG,KAAK;AAAA,KACR,GAAG,MAAM;AAAA,KACT,GAAG,KAAK;AAAA,KACR,GAAG,MAAM;AAAA,KACT,GAAG,KAAK;AAAA,KACR,GAAG,MAAM;AAAA,KACT,GAAG,KAAK;AAAA,KACR,GAAG,KAAK;AAAA,KACR,GAAG,QAAQ;AAAA,KACX,GAAG,OAAO;AAAA,KACV,GAAG,UAAU;AA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X,OAAO,UAAU;",
|
||||
"names": []
|
||||
}
|
||||
Generated
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
const uuidv4 = require("uuid").v4;
|
||||
const TransactionQueries = {
|
||||
setIsolationLevelQuery(value, options) {
|
||||
if (options.parent) {
|
||||
return;
|
||||
}
|
||||
return `SET TRANSACTION ISOLATION LEVEL ${value};`;
|
||||
},
|
||||
generateTransactionId() {
|
||||
return uuidv4();
|
||||
},
|
||||
startTransactionQuery(transaction) {
|
||||
if (transaction.parent) {
|
||||
return `SAVEPOINT ${this.quoteIdentifier(transaction.name, true)};`;
|
||||
}
|
||||
return "START TRANSACTION;";
|
||||
},
|
||||
deferConstraintsQuery() {
|
||||
},
|
||||
setConstraintQuery() {
|
||||
},
|
||||
setDeferredQuery() {
|
||||
},
|
||||
setImmediateQuery() {
|
||||
},
|
||||
commitTransactionQuery(transaction) {
|
||||
if (transaction.parent) {
|
||||
return;
|
||||
}
|
||||
return "COMMIT;";
|
||||
},
|
||||
rollbackTransactionQuery(transaction) {
|
||||
if (transaction.parent) {
|
||||
return `ROLLBACK TO SAVEPOINT ${this.quoteIdentifier(transaction.name, true)};`;
|
||||
}
|
||||
return "ROLLBACK;";
|
||||
}
|
||||
};
|
||||
module.exports = TransactionQueries;
|
||||
//# sourceMappingURL=transaction.js.map
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../../src/dialects/abstract/query-generator/transaction.js"],
|
||||
"sourcesContent": ["'use strict';\n\nconst uuidv4 = require('uuid').v4;\n\nconst TransactionQueries = {\n /**\n * Returns a query that sets the transaction isolation level.\n *\n * @param {string} value The isolation level.\n * @param {object} options An object with options.\n * @returns {string} The generated sql query.\n * @private\n */\n setIsolationLevelQuery(value, options) {\n if (options.parent) {\n return;\n }\n\n return `SET TRANSACTION ISOLATION LEVEL ${value};`;\n },\n\n generateTransactionId() {\n return uuidv4();\n },\n\n /**\n * Returns a query that starts a transaction.\n *\n * @param {Transaction} transaction\n * @returns {string} The generated sql query.\n * @private\n */\n startTransactionQuery(transaction) {\n if (transaction.parent) {\n // force quoting of savepoint identifiers for postgres\n return `SAVEPOINT ${this.quoteIdentifier(transaction.name, true)};`;\n }\n\n return 'START TRANSACTION;';\n },\n\n deferConstraintsQuery() {},\n\n setConstraintQuery() {},\n setDeferredQuery() {},\n setImmediateQuery() {},\n\n /**\n * Returns a query that commits a transaction.\n *\n * @param {Transaction} transaction An object with options.\n * @returns {string} The generated sql query.\n * @private\n */\n commitTransactionQuery(transaction) {\n if (transaction.parent) {\n return;\n }\n\n return 'COMMIT;';\n },\n\n /**\n * Returns a query that rollbacks a transaction.\n *\n * @param {Transaction} transaction\n * @returns {string} The generated sql query.\n * @private\n */\n rollbackTransactionQuery(transaction) {\n if (transaction.parent) {\n // force quoting of savepoint identifiers for postgres\n return `ROLLBACK TO SAVEPOINT ${this.quoteIdentifier(transaction.name, true)};`;\n }\n\n return 'ROLLBACK;';\n }\n};\n\nmodule.exports = TransactionQueries;\n"],
|
||||
"mappings": ";AAEA,MAAM,SAAS,QAAQ,QAAQ;AAE/B,MAAM,qBAAqB;AAAA,EASzB,uBAAuB,OAAO,SAAS;AACrC,QAAI,QAAQ,QAAQ;AAClB;AAAA;AAGF,WAAO,mCAAmC;AAAA;AAAA,EAG5C,wBAAwB;AACtB,WAAO;AAAA;AAAA,EAUT,sBAAsB,aAAa;AACjC,QAAI,YAAY,QAAQ;AAEtB,aAAO,aAAa,KAAK,gBAAgB,YAAY,MAAM;AAAA;AAG7D,WAAO;AAAA;AAAA,EAGT,wBAAwB;AAAA;AAAA,EAExB,qBAAqB;AAAA;AAAA,EACrB,mBAAmB;AAAA;AAAA,EACnB,oBAAoB;AAAA;AAAA,EASpB,uBAAuB,aAAa;AAClC,QAAI,YAAY,QAAQ;AACtB;AAAA;AAGF,WAAO;AAAA;AAAA,EAUT,yBAAyB,aAAa;AACpC,QAAI,YAAY,QAAQ;AAEtB,aAAO,yBAAyB,KAAK,gBAAgB,YAAY,MAAM;AAAA;AAGzE,WAAO;AAAA;AAAA;AAIX,OAAO,UAAU;",
|
||||
"names": []
|
||||
}
|
||||
+569
@@ -0,0 +1,569 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
const _ = require("lodash");
|
||||
const Utils = require("../../utils");
|
||||
const DataTypes = require("../../data-types");
|
||||
const Transaction = require("../../transaction");
|
||||
const QueryTypes = require("../../query-types");
|
||||
class QueryInterface {
|
||||
constructor(sequelize, queryGenerator) {
|
||||
this.sequelize = sequelize;
|
||||
this.queryGenerator = queryGenerator;
|
||||
}
|
||||
async createDatabase(database, options) {
|
||||
options = options || {};
|
||||
const sql = this.queryGenerator.createDatabaseQuery(database, options);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async dropDatabase(database, options) {
|
||||
options = options || {};
|
||||
const sql = this.queryGenerator.dropDatabaseQuery(database);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async createSchema(schema, options) {
|
||||
options = options || {};
|
||||
const sql = this.queryGenerator.createSchema(schema);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async dropSchema(schema, options) {
|
||||
options = options || {};
|
||||
const sql = this.queryGenerator.dropSchema(schema);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async dropAllSchemas(options) {
|
||||
options = options || {};
|
||||
if (!this.queryGenerator._dialect.supports.schemas) {
|
||||
return this.sequelize.drop(options);
|
||||
}
|
||||
const schemas = await this.showAllSchemas(options);
|
||||
return Promise.all(schemas.map((schemaName) => this.dropSchema(schemaName, options)));
|
||||
}
|
||||
async showAllSchemas(options) {
|
||||
options = __spreadProps(__spreadValues({}, options), {
|
||||
raw: true,
|
||||
type: this.sequelize.QueryTypes.SELECT
|
||||
});
|
||||
const showSchemasSql = this.queryGenerator.showSchemasQuery(options);
|
||||
const schemaNames = await this.sequelize.query(showSchemasSql, options);
|
||||
return _.flatten(schemaNames.map((value) => value.schema_name ? value.schema_name : value));
|
||||
}
|
||||
async databaseVersion(options) {
|
||||
return await this.sequelize.query(this.queryGenerator.versionQuery(), __spreadProps(__spreadValues({}, options), { type: QueryTypes.VERSION }));
|
||||
}
|
||||
async createTable(tableName, attributes, options, model) {
|
||||
let sql = "";
|
||||
options = __spreadValues({}, options);
|
||||
if (options && options.uniqueKeys) {
|
||||
_.forOwn(options.uniqueKeys, (uniqueKey) => {
|
||||
if (uniqueKey.customIndex === void 0) {
|
||||
uniqueKey.customIndex = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (model) {
|
||||
options.uniqueKeys = options.uniqueKeys || model.uniqueKeys;
|
||||
}
|
||||
attributes = _.mapValues(attributes, (attribute) => this.sequelize.normalizeAttribute(attribute));
|
||||
await this.ensureEnums(tableName, attributes, options, model);
|
||||
if (!tableName.schema && (options.schema || !!model && model._schema)) {
|
||||
tableName = this.queryGenerator.addSchema({
|
||||
tableName,
|
||||
_schema: !!model && model._schema || options.schema
|
||||
});
|
||||
}
|
||||
attributes = this.queryGenerator.attributesToSQL(attributes, {
|
||||
table: tableName,
|
||||
context: "createTable",
|
||||
withoutForeignKeyConstraints: options.withoutForeignKeyConstraints
|
||||
});
|
||||
sql = this.queryGenerator.createTableQuery(tableName, attributes, options);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async tableExists(tableName, options) {
|
||||
const sql = this.queryGenerator.tableExistsQuery(tableName);
|
||||
const out = await this.sequelize.query(sql, __spreadProps(__spreadValues({}, options), {
|
||||
type: QueryTypes.SHOWTABLES
|
||||
}));
|
||||
return out.length === 1;
|
||||
}
|
||||
async dropTable(tableName, options) {
|
||||
options = __spreadValues({}, options);
|
||||
options.cascade = options.cascade || options.force || false;
|
||||
const sql = this.queryGenerator.dropTableQuery(tableName, options);
|
||||
await this.sequelize.query(sql, options);
|
||||
}
|
||||
async _dropAllTables(tableNames, skip, options) {
|
||||
for (const tableName of tableNames) {
|
||||
if (!skip.includes(tableName.tableName || tableName)) {
|
||||
await this.dropTable(tableName, __spreadProps(__spreadValues({}, options), { cascade: true }));
|
||||
}
|
||||
}
|
||||
}
|
||||
async dropAllTables(options) {
|
||||
options = options || {};
|
||||
const skip = options.skip || [];
|
||||
const tableNames = await this.showAllTables(options);
|
||||
const foreignKeys = await this.getForeignKeysForTables(tableNames, options);
|
||||
for (const tableName of tableNames) {
|
||||
let normalizedTableName = tableName;
|
||||
if (_.isObject(tableName)) {
|
||||
normalizedTableName = `${tableName.schema}.${tableName.tableName}`;
|
||||
}
|
||||
for (const foreignKey of foreignKeys[normalizedTableName]) {
|
||||
await this.sequelize.query(this.queryGenerator.dropForeignKeyQuery(tableName, foreignKey));
|
||||
}
|
||||
}
|
||||
await this._dropAllTables(tableNames, skip, options);
|
||||
}
|
||||
async renameTable(before, after, options) {
|
||||
options = options || {};
|
||||
const sql = this.queryGenerator.renameTableQuery(before, after);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async showAllTables(options) {
|
||||
options = __spreadProps(__spreadValues({}, options), {
|
||||
raw: true,
|
||||
type: QueryTypes.SHOWTABLES
|
||||
});
|
||||
const showTablesSql = this.queryGenerator.showTablesQuery(this.sequelize.config.database);
|
||||
const tableNames = await this.sequelize.query(showTablesSql, options);
|
||||
return _.flatten(tableNames);
|
||||
}
|
||||
async describeTable(tableName, options) {
|
||||
let schema = null;
|
||||
let schemaDelimiter = null;
|
||||
if (typeof options === "string") {
|
||||
schema = options;
|
||||
} else if (typeof options === "object" && options !== null) {
|
||||
schema = options.schema || null;
|
||||
schemaDelimiter = options.schemaDelimiter || null;
|
||||
}
|
||||
if (typeof tableName === "object" && tableName !== null) {
|
||||
schema = tableName.schema;
|
||||
tableName = tableName.tableName;
|
||||
}
|
||||
const sql = this.queryGenerator.describeTableQuery(tableName, schema, schemaDelimiter);
|
||||
options = __spreadProps(__spreadValues({}, options), { type: QueryTypes.DESCRIBE });
|
||||
try {
|
||||
const data = await this.sequelize.query(sql, options);
|
||||
if (_.isEmpty(data)) {
|
||||
throw new Error(`No description found for "${tableName}" table. Check the table name and schema; remember, they _are_ case sensitive.`);
|
||||
}
|
||||
return data;
|
||||
} catch (e) {
|
||||
if (e.original && e.original.code === "ER_NO_SUCH_TABLE") {
|
||||
throw new Error(`No description found for "${tableName}" table. Check the table name and schema; remember, they _are_ case sensitive.`);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async addColumn(table, key, attribute, options) {
|
||||
if (!table || !key || !attribute) {
|
||||
throw new Error("addColumn takes at least 3 arguments (table, attribute name, attribute definition)");
|
||||
}
|
||||
options = options || {};
|
||||
attribute = this.sequelize.normalizeAttribute(attribute);
|
||||
return await this.sequelize.query(this.queryGenerator.addColumnQuery(table, key, attribute), options);
|
||||
}
|
||||
async removeColumn(tableName, attributeName, options) {
|
||||
return this.sequelize.query(this.queryGenerator.removeColumnQuery(tableName, attributeName), options);
|
||||
}
|
||||
normalizeAttribute(dataTypeOrOptions) {
|
||||
let attribute;
|
||||
if (Object.values(DataTypes).includes(dataTypeOrOptions)) {
|
||||
attribute = { type: dataTypeOrOptions, allowNull: true };
|
||||
} else {
|
||||
attribute = dataTypeOrOptions;
|
||||
}
|
||||
return this.sequelize.normalizeAttribute(attribute);
|
||||
}
|
||||
quoteIdentifier(identifier2, force) {
|
||||
return this.queryGenerator.quoteIdentifier(identifier2, force);
|
||||
}
|
||||
quoteIdentifiers(identifiers) {
|
||||
return this.queryGenerator.quoteIdentifiers(identifiers);
|
||||
}
|
||||
async changeColumn(tableName, attributeName, dataTypeOrOptions, options) {
|
||||
options = options || {};
|
||||
const query = this.queryGenerator.attributesToSQL({
|
||||
[attributeName]: this.normalizeAttribute(dataTypeOrOptions)
|
||||
}, {
|
||||
context: "changeColumn",
|
||||
table: tableName
|
||||
});
|
||||
const sql = this.queryGenerator.changeColumnQuery(tableName, query);
|
||||
return this.sequelize.query(sql, options);
|
||||
}
|
||||
async assertTableHasColumn(tableName, columnName, options) {
|
||||
const description = await this.describeTable(tableName, options);
|
||||
if (description[columnName]) {
|
||||
return description;
|
||||
}
|
||||
throw new Error(`Table ${tableName} doesn't have the column ${columnName}`);
|
||||
}
|
||||
async renameColumn(tableName, attrNameBefore, attrNameAfter, options) {
|
||||
options = options || {};
|
||||
const data = (await this.assertTableHasColumn(tableName, attrNameBefore, options))[attrNameBefore];
|
||||
const _options = {};
|
||||
_options[attrNameAfter] = {
|
||||
attribute: attrNameAfter,
|
||||
type: data.type,
|
||||
allowNull: data.allowNull,
|
||||
defaultValue: data.defaultValue
|
||||
};
|
||||
if (data.defaultValue === null && !data.allowNull) {
|
||||
delete _options[attrNameAfter].defaultValue;
|
||||
}
|
||||
const sql = this.queryGenerator.renameColumnQuery(tableName, attrNameBefore, this.queryGenerator.attributesToSQL(_options));
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async addIndex(tableName, attributes, options, rawTablename) {
|
||||
if (!Array.isArray(attributes)) {
|
||||
rawTablename = options;
|
||||
options = attributes;
|
||||
attributes = options.fields;
|
||||
}
|
||||
if (!rawTablename) {
|
||||
rawTablename = tableName;
|
||||
}
|
||||
options = Utils.cloneDeep(options);
|
||||
options.fields = attributes;
|
||||
const sql = this.queryGenerator.addIndexQuery(tableName, options, rawTablename);
|
||||
return await this.sequelize.query(sql, __spreadProps(__spreadValues({}, options), { supportsSearchPath: false }));
|
||||
}
|
||||
async showIndex(tableName, options) {
|
||||
const sql = this.queryGenerator.showIndexesQuery(tableName, options);
|
||||
return await this.sequelize.query(sql, __spreadProps(__spreadValues({}, options), { type: QueryTypes.SHOWINDEXES }));
|
||||
}
|
||||
async getForeignKeysForTables(tableNames, options) {
|
||||
if (tableNames.length === 0) {
|
||||
return {};
|
||||
}
|
||||
options = __spreadProps(__spreadValues({}, options), { type: QueryTypes.FOREIGNKEYS });
|
||||
const results = await Promise.all(tableNames.map((tableName) => this.sequelize.query(this.queryGenerator.getForeignKeysQuery(tableName, this.sequelize.config.database), options)));
|
||||
const result = {};
|
||||
tableNames.forEach((tableName, i) => {
|
||||
if (_.isObject(tableName)) {
|
||||
tableName = `${tableName.schema}.${tableName.tableName}`;
|
||||
}
|
||||
result[tableName] = Array.isArray(results[i]) ? results[i].map((r) => r.constraint_name) : [results[i] && results[i].constraint_name];
|
||||
result[tableName] = result[tableName].filter(_.identity);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
async getForeignKeyReferencesForTable(tableName, options) {
|
||||
const queryOptions = __spreadProps(__spreadValues({}, options), {
|
||||
type: QueryTypes.FOREIGNKEYS
|
||||
});
|
||||
const query = this.queryGenerator.getForeignKeysQuery(tableName, this.sequelize.config.database);
|
||||
return this.sequelize.query(query, queryOptions);
|
||||
}
|
||||
async removeIndex(tableName, indexNameOrAttributes, options) {
|
||||
options = options || {};
|
||||
const sql = this.queryGenerator.removeIndexQuery(tableName, indexNameOrAttributes, options);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async addConstraint(tableName, options) {
|
||||
if (!options.fields) {
|
||||
throw new Error("Fields must be specified through options.fields");
|
||||
}
|
||||
if (!options.type) {
|
||||
throw new Error("Constraint type must be specified through options.type");
|
||||
}
|
||||
options = Utils.cloneDeep(options);
|
||||
const sql = this.queryGenerator.addConstraintQuery(tableName, options);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async showConstraint(tableName, constraintName, options) {
|
||||
const sql = this.queryGenerator.showConstraintsQuery(tableName, constraintName);
|
||||
return await this.sequelize.query(sql, __spreadProps(__spreadValues({}, options), { type: QueryTypes.SHOWCONSTRAINTS }));
|
||||
}
|
||||
async removeConstraint(tableName, constraintName, options) {
|
||||
return this.sequelize.query(this.queryGenerator.removeConstraintQuery(tableName, constraintName), options);
|
||||
}
|
||||
async insert(instance, tableName, values, options) {
|
||||
options = Utils.cloneDeep(options);
|
||||
options.hasTrigger = instance && instance.constructor.options.hasTrigger;
|
||||
const sql = this.queryGenerator.insertQuery(tableName, values, instance && instance.constructor.rawAttributes, options);
|
||||
options.type = QueryTypes.INSERT;
|
||||
options.instance = instance;
|
||||
const results = await this.sequelize.query(sql, options);
|
||||
if (instance)
|
||||
results[0].isNewRecord = false;
|
||||
return results;
|
||||
}
|
||||
async upsert(tableName, insertValues, updateValues, where, options) {
|
||||
options = __spreadValues({}, options);
|
||||
const model = options.model;
|
||||
options.type = QueryTypes.UPSERT;
|
||||
options.updateOnDuplicate = Object.keys(updateValues);
|
||||
options.upsertKeys = options.conflictFields || [];
|
||||
if (options.upsertKeys.length === 0) {
|
||||
const primaryKeys = Object.values(model.primaryKeys).map((item) => item.field);
|
||||
const uniqueKeys = Object.values(model.uniqueKeys).filter((c) => c.fields.length > 0).map((c) => c.fields);
|
||||
const indexKeys = Object.values(model._indexes).filter((c) => c.unique && c.fields.length > 0).map((c) => c.fields);
|
||||
for (const field of options.updateOnDuplicate) {
|
||||
const uniqueKey = uniqueKeys.find((fields) => fields.includes(field));
|
||||
if (uniqueKey) {
|
||||
options.upsertKeys = uniqueKey;
|
||||
break;
|
||||
}
|
||||
const indexKey = indexKeys.find((fields) => fields.includes(field));
|
||||
if (indexKey) {
|
||||
options.upsertKeys = indexKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (options.upsertKeys.length === 0 || _.intersection(options.updateOnDuplicate, primaryKeys).length) {
|
||||
options.upsertKeys = primaryKeys;
|
||||
}
|
||||
options.upsertKeys = _.uniq(options.upsertKeys);
|
||||
}
|
||||
const sql = this.queryGenerator.insertQuery(tableName, insertValues, model.rawAttributes, options);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async bulkInsert(tableName, records, options, attributes) {
|
||||
options = __spreadValues({}, options);
|
||||
options.type = QueryTypes.INSERT;
|
||||
const results = await this.sequelize.query(this.queryGenerator.bulkInsertQuery(tableName, records, options, attributes), options);
|
||||
return results[0];
|
||||
}
|
||||
async update(instance, tableName, values, identifier2, options) {
|
||||
options = __spreadValues({}, options);
|
||||
options.hasTrigger = instance && instance.constructor.options.hasTrigger;
|
||||
const sql = this.queryGenerator.updateQuery(tableName, values, identifier2, options, instance.constructor.rawAttributes);
|
||||
options.type = QueryTypes.UPDATE;
|
||||
options.instance = instance;
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async bulkUpdate(tableName, values, identifier2, options, attributes) {
|
||||
options = Utils.cloneDeep(options);
|
||||
if (typeof identifier2 === "object")
|
||||
identifier2 = Utils.cloneDeep(identifier2);
|
||||
const sql = this.queryGenerator.updateQuery(tableName, values, identifier2, options, attributes);
|
||||
const table = _.isObject(tableName) ? tableName : { tableName };
|
||||
const model = options.model ? options.model : _.find(this.sequelize.modelManager.models, { tableName: table.tableName });
|
||||
options.type = QueryTypes.BULKUPDATE;
|
||||
options.model = model;
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async delete(instance, tableName, identifier2, options) {
|
||||
const cascades = [];
|
||||
const sql = this.queryGenerator.deleteQuery(tableName, identifier2, {}, instance.constructor);
|
||||
options = __spreadValues({}, options);
|
||||
if (!!instance.constructor && !!instance.constructor.associations) {
|
||||
const keys = Object.keys(instance.constructor.associations);
|
||||
const length = keys.length;
|
||||
let association;
|
||||
for (let i = 0; i < length; i++) {
|
||||
association = instance.constructor.associations[keys[i]];
|
||||
if (association.options && association.options.onDelete && association.options.onDelete.toLowerCase() === "cascade" && association.options.useHooks === true) {
|
||||
cascades.push(association.accessors.get);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const cascade of cascades) {
|
||||
let instances = await instance[cascade](options);
|
||||
if (!instances)
|
||||
continue;
|
||||
if (!Array.isArray(instances))
|
||||
instances = [instances];
|
||||
for (const _instance of instances)
|
||||
await _instance.destroy(options);
|
||||
}
|
||||
options.instance = instance;
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async bulkDelete(tableName, where, options, model) {
|
||||
options = Utils.cloneDeep(options);
|
||||
options = _.defaults(options, { limit: null });
|
||||
if (options.truncate === true) {
|
||||
return this.sequelize.query(this.queryGenerator.truncateTableQuery(tableName, options), options);
|
||||
}
|
||||
if (typeof identifier === "object")
|
||||
where = Utils.cloneDeep(where);
|
||||
return await this.sequelize.query(this.queryGenerator.deleteQuery(tableName, where, options, model), options);
|
||||
}
|
||||
async select(model, tableName, optionsArg) {
|
||||
const options = __spreadProps(__spreadValues({}, optionsArg), { type: QueryTypes.SELECT, model });
|
||||
return await this.sequelize.query(this.queryGenerator.selectQuery(tableName, options, model), options);
|
||||
}
|
||||
async increment(model, tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options) {
|
||||
options = Utils.cloneDeep(options);
|
||||
const sql = this.queryGenerator.arithmeticQuery("+", tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options);
|
||||
options.type = QueryTypes.UPDATE;
|
||||
options.model = model;
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async decrement(model, tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options) {
|
||||
options = Utils.cloneDeep(options);
|
||||
const sql = this.queryGenerator.arithmeticQuery("-", tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options);
|
||||
options.type = QueryTypes.UPDATE;
|
||||
options.model = model;
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async rawSelect(tableName, options, attributeSelector, Model) {
|
||||
options = Utils.cloneDeep(options);
|
||||
options = _.defaults(options, {
|
||||
raw: true,
|
||||
plain: true,
|
||||
type: QueryTypes.SELECT
|
||||
});
|
||||
const sql = this.queryGenerator.selectQuery(tableName, options, Model);
|
||||
if (attributeSelector === void 0) {
|
||||
throw new Error("Please pass an attribute selector!");
|
||||
}
|
||||
const data = await this.sequelize.query(sql, options);
|
||||
if (!options.plain) {
|
||||
return data;
|
||||
}
|
||||
const result = data ? data[attributeSelector] : null;
|
||||
if (!options || !options.dataType) {
|
||||
return result;
|
||||
}
|
||||
const dataType = options.dataType;
|
||||
if (dataType instanceof DataTypes.DECIMAL || dataType instanceof DataTypes.FLOAT) {
|
||||
if (result !== null) {
|
||||
return parseFloat(result);
|
||||
}
|
||||
}
|
||||
if (dataType instanceof DataTypes.INTEGER || dataType instanceof DataTypes.BIGINT) {
|
||||
if (result !== null) {
|
||||
return parseInt(result, 10);
|
||||
}
|
||||
}
|
||||
if (dataType instanceof DataTypes.DATE) {
|
||||
if (result !== null && !(result instanceof Date)) {
|
||||
return new Date(result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async createTrigger(tableName, triggerName, timingType, fireOnArray, functionName, functionParams, optionsArray, options) {
|
||||
const sql = this.queryGenerator.createTrigger(tableName, triggerName, timingType, fireOnArray, functionName, functionParams, optionsArray);
|
||||
options = options || {};
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
async dropTrigger(tableName, triggerName, options) {
|
||||
const sql = this.queryGenerator.dropTrigger(tableName, triggerName);
|
||||
options = options || {};
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
async renameTrigger(tableName, oldTriggerName, newTriggerName, options) {
|
||||
const sql = this.queryGenerator.renameTrigger(tableName, oldTriggerName, newTriggerName);
|
||||
options = options || {};
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
async createFunction(functionName, params, returnType, language, body, optionsArray, options) {
|
||||
const sql = this.queryGenerator.createFunction(functionName, params, returnType, language, body, optionsArray, options);
|
||||
options = options || {};
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
async dropFunction(functionName, params, options) {
|
||||
const sql = this.queryGenerator.dropFunction(functionName, params);
|
||||
options = options || {};
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
async renameFunction(oldFunctionName, params, newFunctionName, options) {
|
||||
const sql = this.queryGenerator.renameFunction(oldFunctionName, params, newFunctionName);
|
||||
options = options || {};
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
ensureEnums() {
|
||||
}
|
||||
async setIsolationLevel(transaction, value, options) {
|
||||
if (!transaction || !(transaction instanceof Transaction)) {
|
||||
throw new Error("Unable to set isolation level for a transaction without transaction object!");
|
||||
}
|
||||
if (transaction.parent || !value) {
|
||||
return;
|
||||
}
|
||||
options = __spreadProps(__spreadValues({}, options), { transaction: transaction.parent || transaction });
|
||||
const sql = this.queryGenerator.setIsolationLevelQuery(value, {
|
||||
parent: transaction.parent
|
||||
});
|
||||
if (!sql)
|
||||
return;
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async startTransaction(transaction, options) {
|
||||
if (!transaction || !(transaction instanceof Transaction)) {
|
||||
throw new Error("Unable to start a transaction without transaction object!");
|
||||
}
|
||||
options = __spreadProps(__spreadValues({}, options), { transaction: transaction.parent || transaction });
|
||||
options.transaction.name = transaction.parent ? transaction.name : void 0;
|
||||
const sql = this.queryGenerator.startTransactionQuery(transaction);
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
async deferConstraints(transaction, options) {
|
||||
options = __spreadProps(__spreadValues({}, options), { transaction: transaction.parent || transaction });
|
||||
const sql = this.queryGenerator.deferConstraintsQuery(options);
|
||||
if (sql) {
|
||||
return await this.sequelize.query(sql, options);
|
||||
}
|
||||
}
|
||||
async commitTransaction(transaction, options) {
|
||||
if (!transaction || !(transaction instanceof Transaction)) {
|
||||
throw new Error("Unable to commit a transaction without transaction object!");
|
||||
}
|
||||
if (transaction.parent) {
|
||||
return;
|
||||
}
|
||||
options = __spreadProps(__spreadValues({}, options), {
|
||||
transaction: transaction.parent || transaction,
|
||||
supportsSearchPath: false,
|
||||
completesTransaction: true
|
||||
});
|
||||
const sql = this.queryGenerator.commitTransactionQuery(transaction);
|
||||
const promise = this.sequelize.query(sql, options);
|
||||
transaction.finished = "commit";
|
||||
return await promise;
|
||||
}
|
||||
async rollbackTransaction(transaction, options) {
|
||||
if (!transaction || !(transaction instanceof Transaction)) {
|
||||
throw new Error("Unable to rollback a transaction without transaction object!");
|
||||
}
|
||||
options = __spreadProps(__spreadValues({}, options), {
|
||||
transaction: transaction.parent || transaction,
|
||||
supportsSearchPath: false,
|
||||
completesTransaction: true
|
||||
});
|
||||
options.transaction.name = transaction.parent ? transaction.name : void 0;
|
||||
const sql = this.queryGenerator.rollbackTransactionQuery(transaction);
|
||||
const promise = this.sequelize.query(sql, options);
|
||||
transaction.finished = "rollback";
|
||||
return await promise;
|
||||
}
|
||||
}
|
||||
exports.QueryInterface = QueryInterface;
|
||||
//# sourceMappingURL=query-interface.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../src/dialects/abstract/query-interface.js"],
|
||||
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\n\nconst Utils = require('../../utils');\nconst DataTypes = require('../../data-types');\nconst Transaction = require('../../transaction');\nconst QueryTypes = require('../../query-types');\n\n/**\n * The interface that Sequelize uses to talk to all databases\n */\nclass QueryInterface {\n constructor(sequelize, queryGenerator) {\n this.sequelize = sequelize;\n this.queryGenerator = queryGenerator;\n }\n\n /**\n * Create a database\n *\n * @param {string} database Database name to create\n * @param {object} [options] Query options\n * @param {string} [options.charset] Database default character set, MYSQL only\n * @param {string} [options.collate] Database default collation\n * @param {string} [options.encoding] Database default character set, PostgreSQL only\n * @param {string} [options.ctype] Database character classification, PostgreSQL only\n * @param {string} [options.template] The name of the template from which to create the new database, PostgreSQL only\n *\n * @returns {Promise}\n */\n async createDatabase(database, options) {\n options = options || {};\n const sql = this.queryGenerator.createDatabaseQuery(database, options);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Drop a database\n *\n * @param {string} database Database name to drop\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async dropDatabase(database, options) {\n options = options || {};\n const sql = this.queryGenerator.dropDatabaseQuery(database);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Create a schema\n *\n * @param {string} schema Schema name to create\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async createSchema(schema, options) {\n options = options || {};\n const sql = this.queryGenerator.createSchema(schema);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Drop a schema\n *\n * @param {string} schema Schema name to drop\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async dropSchema(schema, options) {\n options = options || {};\n const sql = this.queryGenerator.dropSchema(schema);\n return await this.sequelize.query(sql, options);\n }\n\n /**\n * Drop all schemas\n *\n * @param {object} [options] Query options\n *\n * @returns {Promise}\n */\n async dropAllSchemas(options) {\n options = options || {};\n\n if (!this.queryGenerator._dialect.supports.schemas) {\n return this.sequelize.drop(options);\n }\n const schemas = await this.showAllSchemas(options);\n return Promise.all(schemas.map(schemaName => this.dropSchema(schemaName, options)));\n }\n\n /**\n * Show all schemas\n *\n * @param {object} [options] Query options\n *\n * @returns {Promise<Array>}\n */\n async showAllSchemas(options) {\n options = {\n ...options,\n raw: true,\n type: this.sequelize.QueryTypes.SELECT\n };\n\n const showSchemasSql = this.queryGenerator.showSchemasQuery(options);\n\n const schemaNames = await this.sequelize.query(showSchemasSql, options);\n\n return _.flatten(schemaNames.map(value => value.schema_name ? value.schema_name : value));\n }\n\n /**\n * Return database version\n *\n * @param {object} [options] Query options\n * @param {QueryType} [options.type] Query type\n *\n * @returns {Promise}\n * @private\n */\n async databaseVersion(options) {\n return await this.sequelize.query(\n this.queryGenerator.versionQuery(),\n { ...options, type: QueryTypes.VERSION }\n );\n }\n\n /**\n * Create a table with given set of attributes\n *\n * ```js\n * queryInterface.createTable(\n * 'nameOfTheNewTable',\n * {\n * id: {\n * type: Sequelize.INTEGER,\n * primaryKey: true,\n * autoIncrement: true\n * },\n * createdAt: {\n * type: Sequelize.DATE\n * },\n * updatedAt: {\n * type: Sequelize.DATE\n * },\n * attr1: Sequelize.STRING,\n * attr2: Sequelize.INTEGER,\n * attr3: {\n * type: Sequelize.BOOLEAN,\n * defaultValue: false,\n * allowNull: false\n * },\n * //foreign key usage\n * attr4: {\n * type: Sequelize.INTEGER,\n * references: {\n * model: 'another_table_name',\n * key: 'id'\n * },\n * onUpdate: 'cascade',\n * onDelete: 'cascade'\n * }\n * },\n * {\n * engine: 'MYISAM', // default: 'InnoDB'\n * charset: 'latin1', // default: null\n * schema: 'public', // default: public, PostgreSQL only.\n * comment: 'my table', // comment for table\n * collate: 'latin1_danish_ci' // collation, MYSQL only\n * }\n * )\n * ``Line truncated
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,QAAQ;AAElB,MAAM,QAAQ,QAAQ;AACtB,MAAM,YAAY,QAAQ;AAC1B,MAAM,cAAc,QAAQ;AAC5B,MAAM,aAAa,QAAQ;AAK3B,qBAAqB;AAAA,EACnB,YAAY,WAAW,gBAAgB;AACrC,SAAK,YAAY;AACjB,SAAK,iBAAiB;AAAA;AAAA,QAgBlB,eAAe,UAAU,SAAS;AACtC,cAAU,WAAW;AACrB,UAAM,MAAM,KAAK,eAAe,oBAAoB,UAAU;AAC9D,WAAO,MAAM,KAAK,UAAU,MAAM,KAAK;AAAA;AAAA,QAWnC,aAAa,UAAU,SAAS;AACpC,c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AAET,UAAM,IAAI,MAAM,SAAS,qCAAqC;AAAA;AAAA,QAa1D,aAAa,WAAW,gBAAgB,eAAe,SAAS;AACpE,cAAU,WAAW;AACrB,UAAM,OAAQ,OAAM,KAAK,qBAAqB,WAAW,gBAAgB,UAAU;AAEnF,UAAM,WAAW;AAEjB,aAAS,iBAAiB;AAAA,MACxB,WAAW;AAAA,MACX,MAAM,KAAK;AAAA,MACX,WAAW,KAAK;AAAA,MAChB,cAAc,KAAK;AAAA;AAIrB,QAAI,KAAK,iBAAiB,QAAQ,CAAC,KAAK,WAAW;AACjD,aAAO,SAAS,eAAe;AAAA;AAGjC,UAAM,MAAM,KAAK,eAAe,kBAC9B,WACA,gBACA,KAAK,eAAe,gBAAgB;AAEtC,WAAO,MAAM,KAAK,UAAU,MAAM,KAAK;AAAA;AAAA,QAqBnC,SAAS,WAAW,YAAY,SAAS,cAAc;AAE3D,QAAI,CAALine truncated
|
||||
"names": []
|
||||
}
|
||||
+546
@@ -0,0 +1,546 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
const _ = require("lodash");
|
||||
const SqlString = require("../../sql-string");
|
||||
const QueryTypes = require("../../query-types");
|
||||
const Dot = require("dottie");
|
||||
const deprecations = require("../../utils/deprecations");
|
||||
const uuid = require("uuid").v4;
|
||||
const { safeStringifyJson } = require("../../utils.js");
|
||||
class AbstractQuery {
|
||||
constructor(connection, sequelize, options) {
|
||||
this.uuid = uuid();
|
||||
this.connection = connection;
|
||||
this.instance = options.instance;
|
||||
this.model = options.model;
|
||||
this.sequelize = sequelize;
|
||||
this.options = __spreadValues({
|
||||
plain: false,
|
||||
raw: false,
|
||||
logging: console.log
|
||||
}, options);
|
||||
this.checkLoggingOption();
|
||||
if (options.rawErrors) {
|
||||
this.formatError = AbstractQuery.prototype.formatError;
|
||||
}
|
||||
}
|
||||
static formatBindParameters(sql, values, dialect, replacementFunc, options) {
|
||||
if (!values) {
|
||||
return [sql, []];
|
||||
}
|
||||
options = options || {};
|
||||
if (typeof replacementFunc !== "function") {
|
||||
options = replacementFunc || {};
|
||||
replacementFunc = void 0;
|
||||
}
|
||||
if (!replacementFunc) {
|
||||
if (options.skipValueReplace) {
|
||||
replacementFunc = (match, key, values2) => {
|
||||
if (values2[key] !== void 0) {
|
||||
return match;
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
} else {
|
||||
replacementFunc = (match, key, values2, timeZone2, dialect2) => {
|
||||
if (values2[key] !== void 0) {
|
||||
return SqlString.escape(values2[key], timeZone2, dialect2);
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
}
|
||||
} else if (options.skipValueReplace) {
|
||||
const origReplacementFunc = replacementFunc;
|
||||
replacementFunc = (match, key, values2, timeZone2, dialect2, options2) => {
|
||||
if (origReplacementFunc(match, key, values2, timeZone2, dialect2, options2) !== void 0) {
|
||||
return match;
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
}
|
||||
const timeZone = null;
|
||||
const list = Array.isArray(values);
|
||||
sql = sql.replace(/\B\$(\$|\w+)/g, (match, key) => {
|
||||
if (key === "$") {
|
||||
return options.skipUnescape ? match : key;
|
||||
}
|
||||
let replVal;
|
||||
if (list) {
|
||||
if (key.match(/^[1-9]\d*$/)) {
|
||||
key = key - 1;
|
||||
replVal = replacementFunc(match, key, values, timeZone, dialect, options);
|
||||
}
|
||||
} else if (!key.match(/^\d*$/)) {
|
||||
replVal = replacementFunc(match, key, values, timeZone, dialect, options);
|
||||
}
|
||||
if (replVal === void 0) {
|
||||
throw new Error(`Named bind parameter "${match}" has no value in the given object.`);
|
||||
}
|
||||
return replVal;
|
||||
});
|
||||
return [sql, []];
|
||||
}
|
||||
formatError(error, errStack) {
|
||||
error.stack = errStack;
|
||||
return error;
|
||||
}
|
||||
run() {
|
||||
throw new Error("The run method wasn't overwritten!");
|
||||
}
|
||||
checkLoggingOption() {
|
||||
if (this.options.logging === true) {
|
||||
deprecations.noTrueLogging();
|
||||
this.options.logging = console.log;
|
||||
}
|
||||
}
|
||||
getInsertIdField() {
|
||||
return "insertId";
|
||||
}
|
||||
getUniqueConstraintErrorMessage(field) {
|
||||
let message = field ? `${field} must be unique` : "Must be unique";
|
||||
if (field && this.model) {
|
||||
for (const key of Object.keys(this.model.uniqueKeys)) {
|
||||
if (this.model.uniqueKeys[key].fields.includes(field.replace(/"/g, ""))) {
|
||||
if (this.model.uniqueKeys[key].msg) {
|
||||
message = this.model.uniqueKeys[key].msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
isRawQuery() {
|
||||
return this.options.type === QueryTypes.RAW;
|
||||
}
|
||||
isVersionQuery() {
|
||||
return this.options.type === QueryTypes.VERSION;
|
||||
}
|
||||
isUpsertQuery() {
|
||||
return this.options.type === QueryTypes.UPSERT;
|
||||
}
|
||||
isInsertQuery(results, metaData) {
|
||||
let result = true;
|
||||
if (this.options.type === QueryTypes.INSERT) {
|
||||
return true;
|
||||
}
|
||||
result = result && this.sql.toLowerCase().startsWith("insert into");
|
||||
result = result && (!results || Object.prototype.hasOwnProperty.call(results, this.getInsertIdField()));
|
||||
result = result && (!metaData || Object.prototype.hasOwnProperty.call(metaData, this.getInsertIdField()));
|
||||
return result;
|
||||
}
|
||||
handleInsertQuery(results, metaData) {
|
||||
if (this.instance) {
|
||||
const autoIncrementAttribute = this.model.autoIncrementAttribute;
|
||||
let id = null;
|
||||
id = id || results && results[this.getInsertIdField()];
|
||||
id = id || metaData && metaData[this.getInsertIdField()];
|
||||
this.instance[autoIncrementAttribute] = id;
|
||||
}
|
||||
}
|
||||
isShowTablesQuery() {
|
||||
return this.options.type === QueryTypes.SHOWTABLES;
|
||||
}
|
||||
handleShowTablesQuery(results) {
|
||||
return _.flatten(results.map((resultSet) => Object.values(resultSet)));
|
||||
}
|
||||
isShowIndexesQuery() {
|
||||
return this.options.type === QueryTypes.SHOWINDEXES;
|
||||
}
|
||||
isShowConstraintsQuery() {
|
||||
return this.options.type === QueryTypes.SHOWCONSTRAINTS;
|
||||
}
|
||||
isDescribeQuery() {
|
||||
return this.options.type === QueryTypes.DESCRIBE;
|
||||
}
|
||||
isSelectQuery() {
|
||||
return this.options.type === QueryTypes.SELECT;
|
||||
}
|
||||
isBulkUpdateQuery() {
|
||||
return this.options.type === QueryTypes.BULKUPDATE;
|
||||
}
|
||||
isBulkDeleteQuery() {
|
||||
return this.options.type === QueryTypes.BULKDELETE;
|
||||
}
|
||||
isForeignKeysQuery() {
|
||||
return this.options.type === QueryTypes.FOREIGNKEYS;
|
||||
}
|
||||
isUpdateQuery() {
|
||||
return this.options.type === QueryTypes.UPDATE;
|
||||
}
|
||||
handleSelectQuery(results) {
|
||||
let result = null;
|
||||
if (this.options.fieldMap) {
|
||||
const fieldMap = this.options.fieldMap;
|
||||
results = results.map((result2) => _.reduce(fieldMap, (result3, name, field) => {
|
||||
if (result3[field] !== void 0 && name !== field) {
|
||||
result3[name] = result3[field];
|
||||
delete result3[field];
|
||||
}
|
||||
return result3;
|
||||
}, result2));
|
||||
}
|
||||
if (this.options.raw) {
|
||||
result = results.map((result2) => {
|
||||
let o = {};
|
||||
for (const key in result2) {
|
||||
if (Object.prototype.hasOwnProperty.call(result2, key)) {
|
||||
o[key] = result2[key];
|
||||
}
|
||||
}
|
||||
if (this.options.nest) {
|
||||
o = Dot.transform(o);
|
||||
}
|
||||
return o;
|
||||
});
|
||||
} else if (this.options.hasJoin === true) {
|
||||
results = AbstractQuery._groupJoinData(results, {
|
||||
model: this.model,
|
||||
includeMap: this.options.includeMap,
|
||||
includeNames: this.options.includeNames
|
||||
}, {
|
||||
checkExisting: this.options.hasMultiAssociation
|
||||
});
|
||||
result = this.model.bulkBuild(results, {
|
||||
isNewRecord: false,
|
||||
include: this.options.include,
|
||||
includeNames: this.options.includeNames,
|
||||
includeMap: this.options.includeMap,
|
||||
includeValidated: true,
|
||||
attributes: this.options.originalAttributes || this.options.attributes,
|
||||
raw: true
|
||||
});
|
||||
} else {
|
||||
result = this.model.bulkBuild(results, {
|
||||
isNewRecord: false,
|
||||
raw: true,
|
||||
attributes: this.options.originalAttributes || this.options.attributes
|
||||
});
|
||||
}
|
||||
if (this.options.plain) {
|
||||
result = result.length === 0 ? null : result[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
isShowOrDescribeQuery() {
|
||||
let result = false;
|
||||
result = result || this.sql.toLowerCase().startsWith("show");
|
||||
result = result || this.sql.toLowerCase().startsWith("describe");
|
||||
return result;
|
||||
}
|
||||
isCallQuery() {
|
||||
return this.sql.toLowerCase().startsWith("call");
|
||||
}
|
||||
_logQuery(sql, debugContext, parameters) {
|
||||
const { connection, options } = this;
|
||||
const benchmark = this.sequelize.options.benchmark || options.benchmark;
|
||||
const logQueryParameters = this.sequelize.options.logQueryParameters || options.logQueryParameters;
|
||||
const startTime = Date.now();
|
||||
let logParameter = "";
|
||||
if (logQueryParameters && parameters) {
|
||||
const delimiter = sql.endsWith(";") ? "" : ";";
|
||||
let paramStr;
|
||||
if (Array.isArray(parameters)) {
|
||||
paramStr = parameters.map((p) => safeStringifyJson(p)).join(", ");
|
||||
} else {
|
||||
paramStr = safeStringifyJson(parameters);
|
||||
}
|
||||
logParameter = `${delimiter} ${paramStr}`;
|
||||
}
|
||||
const fmt = `(${connection.uuid || "default"}): ${sql}${logParameter}`;
|
||||
const msg = `Executing ${fmt}`;
|
||||
debugContext(msg);
|
||||
if (!benchmark) {
|
||||
this.sequelize.log(`Executing ${fmt}`, options);
|
||||
}
|
||||
return () => {
|
||||
const afterMsg = `Executed ${fmt}`;
|
||||
debugContext(afterMsg);
|
||||
if (benchmark) {
|
||||
this.sequelize.log(afterMsg, Date.now() - startTime, options);
|
||||
}
|
||||
};
|
||||
}
|
||||
static _groupJoinData(rows, includeOptions, options) {
|
||||
if (!rows.length) {
|
||||
return [];
|
||||
}
|
||||
let i;
|
||||
let length;
|
||||
let $i;
|
||||
let $length;
|
||||
let rowsI;
|
||||
let row;
|
||||
const rowsLength = rows.length;
|
||||
let keys;
|
||||
let key;
|
||||
let keyI;
|
||||
let keyLength;
|
||||
let prevKey;
|
||||
let values;
|
||||
let topValues;
|
||||
let topExists;
|
||||
const checkExisting = options.checkExisting;
|
||||
let itemHash;
|
||||
let parentHash;
|
||||
let topHash;
|
||||
const results = checkExisting ? [] : new Array(rowsLength);
|
||||
const resultMap = {};
|
||||
const includeMap = {};
|
||||
let $keyPrefix;
|
||||
let $keyPrefixString;
|
||||
let $prevKeyPrefixString;
|
||||
let $prevKeyPrefix;
|
||||
let $lastKeyPrefix;
|
||||
let $current;
|
||||
let $parent;
|
||||
let previousPiece;
|
||||
const buildIncludeMap = (piece) => {
|
||||
if (Object.prototype.hasOwnProperty.call($current.includeMap, piece)) {
|
||||
includeMap[key] = $current = $current.includeMap[piece];
|
||||
if (previousPiece) {
|
||||
previousPiece = `${previousPiece}.${piece}`;
|
||||
} else {
|
||||
previousPiece = piece;
|
||||
}
|
||||
includeMap[previousPiece] = $current;
|
||||
}
|
||||
};
|
||||
const keyPrefixStringMemo = {};
|
||||
const keyPrefixString = (key2, memo) => {
|
||||
if (!Object.prototype.hasOwnProperty.call(memo, key2)) {
|
||||
memo[key2] = key2.substr(0, key2.lastIndexOf("."));
|
||||
}
|
||||
return memo[key2];
|
||||
};
|
||||
const removeKeyPrefixMemo = {};
|
||||
const removeKeyPrefix = (key2) => {
|
||||
if (!Object.prototype.hasOwnProperty.call(removeKeyPrefixMemo, key2)) {
|
||||
const index = key2.lastIndexOf(".");
|
||||
removeKeyPrefixMemo[key2] = key2.substr(index === -1 ? 0 : index + 1);
|
||||
}
|
||||
return removeKeyPrefixMemo[key2];
|
||||
};
|
||||
const keyPrefixMemo = {};
|
||||
const keyPrefix = (key2) => {
|
||||
if (!Object.prototype.hasOwnProperty.call(keyPrefixMemo, key2)) {
|
||||
const prefixString = keyPrefixString(key2, keyPrefixStringMemo);
|
||||
if (!Object.prototype.hasOwnProperty.call(keyPrefixMemo, prefixString)) {
|
||||
keyPrefixMemo[prefixString] = prefixString ? prefixString.split(".") : [];
|
||||
}
|
||||
keyPrefixMemo[key2] = keyPrefixMemo[prefixString];
|
||||
}
|
||||
return keyPrefixMemo[key2];
|
||||
};
|
||||
const lastKeyPrefixMemo = {};
|
||||
const lastKeyPrefix = (key2) => {
|
||||
if (!Object.prototype.hasOwnProperty.call(lastKeyPrefixMemo, key2)) {
|
||||
const prefix2 = keyPrefix(key2);
|
||||
const length2 = prefix2.length;
|
||||
lastKeyPrefixMemo[key2] = !length2 ? "" : prefix2[length2 - 1];
|
||||
}
|
||||
return lastKeyPrefixMemo[key2];
|
||||
};
|
||||
const getUniqueKeyAttributes = (model) => {
|
||||
let uniqueKeyAttributes2 = _.chain(model.uniqueKeys);
|
||||
uniqueKeyAttributes2 = uniqueKeyAttributes2.result(`${uniqueKeyAttributes2.findKey()}.fields`).map((field) => _.findKey(model.attributes, (chr) => chr.field === field)).value();
|
||||
return uniqueKeyAttributes2;
|
||||
};
|
||||
const stringify = (obj) => obj instanceof Buffer ? obj.toString("hex") : obj;
|
||||
let primaryKeyAttributes;
|
||||
let uniqueKeyAttributes;
|
||||
let prefix;
|
||||
for (rowsI = 0; rowsI < rowsLength; rowsI++) {
|
||||
row = rows[rowsI];
|
||||
if (rowsI === 0) {
|
||||
keys = _.sortBy(Object.keys(row), (item) => [item.split(".").length]);
|
||||
keyLength = keys.length;
|
||||
}
|
||||
if (checkExisting) {
|
||||
topExists = false;
|
||||
$length = includeOptions.model.primaryKeyAttributes.length;
|
||||
topHash = "";
|
||||
if ($length === 1) {
|
||||
topHash = stringify(row[includeOptions.model.primaryKeyAttributes[0]]);
|
||||
} else if ($length > 1) {
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
topHash += stringify(row[includeOptions.model.primaryKeyAttributes[$i]]);
|
||||
}
|
||||
} else if (!_.isEmpty(includeOptions.model.uniqueKeys)) {
|
||||
uniqueKeyAttributes = getUniqueKeyAttributes(includeOptions.model);
|
||||
for ($i = 0; $i < uniqueKeyAttributes.length; $i++) {
|
||||
topHash += row[uniqueKeyAttributes[$i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
topValues = values = {};
|
||||
$prevKeyPrefix = void 0;
|
||||
for (keyI = 0; keyI < keyLength; keyI++) {
|
||||
key = keys[keyI];
|
||||
$keyPrefixString = keyPrefixString(key, keyPrefixStringMemo);
|
||||
$keyPrefix = keyPrefix(key);
|
||||
if (rowsI === 0 && !Object.prototype.hasOwnProperty.call(includeMap, key)) {
|
||||
if (!$keyPrefix.length) {
|
||||
includeMap[key] = includeMap[""] = includeOptions;
|
||||
} else {
|
||||
$current = includeOptions;
|
||||
previousPiece = void 0;
|
||||
$keyPrefix.forEach(buildIncludeMap);
|
||||
}
|
||||
}
|
||||
if ($prevKeyPrefix !== void 0 && $prevKeyPrefix !== $keyPrefix) {
|
||||
if (checkExisting) {
|
||||
length = $prevKeyPrefix.length;
|
||||
$parent = null;
|
||||
parentHash = null;
|
||||
if (length) {
|
||||
for (i = 0; i < length; i++) {
|
||||
prefix = $parent ? `${$parent}.${$prevKeyPrefix[i]}` : $prevKeyPrefix[i];
|
||||
primaryKeyAttributes = includeMap[prefix].model.primaryKeyAttributes;
|
||||
$length = primaryKeyAttributes.length;
|
||||
itemHash = prefix;
|
||||
if ($length === 1) {
|
||||
itemHash += stringify(row[`${prefix}.${primaryKeyAttributes[0]}`]);
|
||||
} else if ($length > 1) {
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
itemHash += stringify(row[`${prefix}.${primaryKeyAttributes[$i]}`]);
|
||||
}
|
||||
} else if (!_.isEmpty(includeMap[prefix].model.uniqueKeys)) {
|
||||
uniqueKeyAttributes = getUniqueKeyAttributes(includeMap[prefix].model);
|
||||
for ($i = 0; $i < uniqueKeyAttributes.length; $i++) {
|
||||
itemHash += row[`${prefix}.${uniqueKeyAttributes[$i]}`];
|
||||
}
|
||||
}
|
||||
if (!parentHash) {
|
||||
parentHash = topHash;
|
||||
}
|
||||
itemHash = parentHash + itemHash;
|
||||
$parent = prefix;
|
||||
if (i < length - 1) {
|
||||
parentHash = itemHash;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemHash = topHash;
|
||||
}
|
||||
if (itemHash === topHash) {
|
||||
if (!resultMap[itemHash]) {
|
||||
resultMap[itemHash] = values;
|
||||
} else {
|
||||
topExists = true;
|
||||
}
|
||||
} else if (!resultMap[itemHash]) {
|
||||
$parent = resultMap[parentHash];
|
||||
$lastKeyPrefix = lastKeyPrefix(prevKey);
|
||||
if (includeMap[prevKey].association.isSingleAssociation) {
|
||||
if ($parent) {
|
||||
$parent[$lastKeyPrefix] = resultMap[itemHash] = values;
|
||||
}
|
||||
} else {
|
||||
if (!$parent[$lastKeyPrefix]) {
|
||||
$parent[$lastKeyPrefix] = [];
|
||||
}
|
||||
$parent[$lastKeyPrefix].push(resultMap[itemHash] = values);
|
||||
}
|
||||
}
|
||||
values = {};
|
||||
} else {
|
||||
$current = topValues;
|
||||
length = $keyPrefix.length;
|
||||
if (length) {
|
||||
for (i = 0; i < length; i++) {
|
||||
if (i === length - 1) {
|
||||
values = $current[$keyPrefix[i]] = {};
|
||||
}
|
||||
$current = $current[$keyPrefix[i]] || {};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
values[removeKeyPrefix(key)] = row[key];
|
||||
prevKey = key;
|
||||
$prevKeyPrefix = $keyPrefix;
|
||||
$prevKeyPrefixString = $keyPrefixString;
|
||||
}
|
||||
if (checkExisting) {
|
||||
length = $prevKeyPrefix.length;
|
||||
$parent = null;
|
||||
parentHash = null;
|
||||
if (length) {
|
||||
for (i = 0; i < length; i++) {
|
||||
prefix = $parent ? `${$parent}.${$prevKeyPrefix[i]}` : $prevKeyPrefix[i];
|
||||
primaryKeyAttributes = includeMap[prefix].model.primaryKeyAttributes;
|
||||
$length = primaryKeyAttributes.length;
|
||||
itemHash = prefix;
|
||||
if ($length === 1) {
|
||||
itemHash += stringify(row[`${prefix}.${primaryKeyAttributes[0]}`]);
|
||||
} else if ($length > 0) {
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
itemHash += stringify(row[`${prefix}.${primaryKeyAttributes[$i]}`]);
|
||||
}
|
||||
} else if (!_.isEmpty(includeMap[prefix].model.uniqueKeys)) {
|
||||
uniqueKeyAttributes = getUniqueKeyAttributes(includeMap[prefix].model);
|
||||
for ($i = 0; $i < uniqueKeyAttributes.length; $i++) {
|
||||
itemHash += row[`${prefix}.${uniqueKeyAttributes[$i]}`];
|
||||
}
|
||||
}
|
||||
if (!parentHash) {
|
||||
parentHash = topHash;
|
||||
}
|
||||
itemHash = parentHash + itemHash;
|
||||
$parent = prefix;
|
||||
if (i < length - 1) {
|
||||
parentHash = itemHash;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemHash = topHash;
|
||||
}
|
||||
if (itemHash === topHash) {
|
||||
if (!resultMap[itemHash]) {
|
||||
resultMap[itemHash] = values;
|
||||
} else {
|
||||
topExists = true;
|
||||
}
|
||||
} else if (!resultMap[itemHash]) {
|
||||
$parent = resultMap[parentHash];
|
||||
$lastKeyPrefix = lastKeyPrefix(prevKey);
|
||||
if (includeMap[prevKey].association.isSingleAssociation) {
|
||||
if ($parent) {
|
||||
$parent[$lastKeyPrefix] = resultMap[itemHash] = values;
|
||||
}
|
||||
} else {
|
||||
if (!$parent[$lastKeyPrefix]) {
|
||||
$parent[$lastKeyPrefix] = [];
|
||||
}
|
||||
$parent[$lastKeyPrefix].push(resultMap[itemHash] = values);
|
||||
}
|
||||
}
|
||||
if (!topExists) {
|
||||
results.push(topValues);
|
||||
}
|
||||
} else {
|
||||
results[rowsI] = topValues;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
module.exports = AbstractQuery;
|
||||
module.exports.AbstractQuery = AbstractQuery;
|
||||
module.exports.default = AbstractQuery;
|
||||
//# sourceMappingURL=query.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../src/dialects/abstract/query.js"],
|
||||
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\nconst SqlString = require('../../sql-string');\nconst QueryTypes = require('../../query-types');\nconst Dot = require('dottie');\nconst deprecations = require('../../utils/deprecations');\nconst uuid = require('uuid').v4;\nconst { safeStringifyJson } = require('../../utils.js');\n\nclass AbstractQuery {\n\n constructor(connection, sequelize, options) {\n this.uuid = uuid();\n this.connection = connection;\n this.instance = options.instance;\n this.model = options.model;\n this.sequelize = sequelize;\n this.options = {\n plain: false,\n raw: false,\n // eslint-disable-next-line no-console\n logging: console.log,\n ...options\n };\n this.checkLoggingOption();\n\n if (options.rawErrors) {\n // The default implementation in AbstractQuery just returns the same\n // error object. By overidding this.formatError, this saves every dialect\n // having to check for options.rawErrors in their own formatError\n // implementations.\n this.formatError = AbstractQuery.prototype.formatError;\n }\n }\n\n /**\n * rewrite query with parameters\n *\n * Examples:\n *\n * query.formatBindParameters('select $1 as foo', ['fooval']);\n *\n * query.formatBindParameters('select $foo as foo', { foo: 'fooval' });\n *\n * Options\n * skipUnescape: bool, skip unescaping $$\n * skipValueReplace: bool, do not replace (but do unescape $$). Check correct syntax and if all values are available\n *\n * @param {string} sql\n * @param {object|Array} values\n * @param {string} dialect\n * @param {Function} [replacementFunc]\n * @param {object} [options]\n * @private\n */\n static formatBindParameters(sql, values, dialect, replacementFunc, options) {\n if (!values) {\n return [sql, []];\n }\n\n options = options || {};\n if (typeof replacementFunc !== 'function') {\n options = replacementFunc || {};\n replacementFunc = undefined;\n }\n\n if (!replacementFunc) {\n if (options.skipValueReplace) {\n replacementFunc = (match, key, values) => {\n if (values[key] !== undefined) {\n return match;\n }\n return undefined;\n };\n } else {\n replacementFunc = (match, key, values, timeZone, dialect) => {\n if (values[key] !== undefined) {\n return SqlString.escape(values[key], timeZone, dialect);\n }\n return undefined;\n };\n }\n } else if (options.skipValueReplace) {\n const origReplacementFunc = replacementFunc;\n replacementFunc = (match, key, values, timeZone, dialect, options) => {\n if (origReplacementFunc(match, key, values, timeZone, dialect, options) !== undefined) {\n return match;\n }\n return undefined;\n };\n }\n\n const timeZone = null;\n const list = Array.isArray(values);\n sql = sql.replace(/\\B\\$(\\$|\\w+)/g, (match, key) => {\n if ('$' === key) {\n return options.skipUnescape ? match : key;\n }\n\n let replVal;\n if (list) {\n if (key.match(/^[1-9]\\d*$/)) {\n key = key - 1;\n replVal = replacementFunc(match, key, values, timeZone, dialect, options);\n }\n } else if (!key.match(/^\\d*$/)) {\n replVal = replacementFunc(match, key, values, timeZone, dialect, options);\n }\n if (replVal === undefined) {\n throw new Error(`Named bind parameter \"${match}\" has no value in the given object.`);\n }\n return replVal;\n });\n return [sql, []];\n }\n\n /**\n * Formats a raw database error from the database library into a common Sequelize exception.\n *\n * @param {Error} error The exception object.\n * @param {object} errStack The stack trace that started the database query.\n * @returns {BaseError} the new formatted error object.\n */\n formatError(error, errStack) {\n // Default implementation, no formatting.\n // Each dialect overrides this method to parse errors from their respective the database engines.\n error.stack = errStack;\n\n return error;\n }\n\n /**\n * Execute the passed sql query.\n *\n * Examples:\n *\n * query.run('SELECT 1')\n *\n * @private\n */\n run() {\n throw new Error('The run method wasn\\'t overwritten!');\n }\n\n /**\n * Check the logging option of the instance and print deprecation warnings.\n *\n * @private\n */\n checkLoggingOption() {\n if (this.options.logging === true) {\n deprecations.noTrueLogging();\n // eslint-disable-next-line no-console\n this.options.logging = console.log;\n }\n }\n\n /**\n * Get the attributes of an insert query, which contains the just inserted id.\n *\n * @returns {string} The field name.\n * @private\n */\n getInsertIdField() {\n return 'insertId';\n }\n\n getUniqueConstraintErroLine truncated
|
||||
"mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,QAAQ;AAClB,MAAM,YAAY,QAAQ;AAC1B,MAAM,aAAa,QAAQ;AAC3B,MAAM,MAAM,QAAQ;AACpB,MAAM,eAAe,QAAQ;AAC7B,MAAM,OAAO,QAAQ,QAAQ;AAC7B,MAAM,EAAE,sBAAsB,QAAQ;AAEtC,oBAAoB;AAAA,EAElB,YAAY,YAAY,WAAW,SAAS;AAC1C,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW,QAAQ;AACxB,SAAK,QAAQ,QAAQ;AACrB,SAAK,YAAY;AACjB,SAAK,UAAU;AAAA,MACb,OAAO;AAAA,MACP,KAAK;AAAA,MAEL,SAAS,QAAQ;AAAA,OACd;AAEL,SAAK;AAEL,QAAI,QAAQ,WAAW;AAKrB,WAAK,cAAc,cAAc,UAAU;AAAA;AAAA;AAAA,SAwBxC,qBAAqB,KAAK,QAAQ,SAAS,iBAAiB,SAAS;AAC1E,QAAI,CAAC,QAAQ;AACX,aAAO,CAAC,KAAK;AAAA;AAGf,cAAU,WAAW;AACrB,QAAI,OAAO,oBAAoB,YAAY;AACzC,gBAAU,mBAAmB;AAC7B,wBAAkB;AAAA;AAGpB,QAAI,CAAC,iBAAiB;AACpB,UAAI,QAAQ,kBAAkB;AAC5B,0BAAkB,CAAC,OAAO,KAAK,YAAW;AACxC,cAAI,QAAO,SAAS,QAAW;AAC7B,mBAAO;AAAA;AAET,iBAAO;AAAA;AAAA,aAEJ;AACL,0BAAkB,CAAC,OAAO,KAAK,SAAQ,WAAU,aAAY;AAC3D,cAAI,QAAO,SAAS,QAAW;AAC7B,mBAAO,UAAU,OAAO,QAAO,MAAM,WAAU;AAA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