API/api.medcify.app/node_modules/sequelize/lib/dialects/mysql/query.js.map

8 lines
15 KiB
Plaintext
Raw Normal View History

2022-09-26 06:11:44 +00:00
{
"version": 3,
"sources": ["../../../src/dialects/mysql/query.js"],
"sourcesContent": ["'use strict';\n\nconst AbstractQuery = require('../abstract/query');\nconst sequelizeErrors = require('../../errors');\nconst _ = require('lodash');\nconst { logger } = require('../../utils/logger');\n\nconst ER_DUP_ENTRY = 1062;\nconst ER_DEADLOCK = 1213;\nconst ER_ROW_IS_REFERENCED = 1451;\nconst ER_NO_REFERENCED_ROW = 1452;\n\nconst debug = logger.debugContext('sql:mysql');\n\nclass Query extends AbstractQuery {\n constructor(connection, sequelize, options) {\n super(connection, sequelize, { showWarnings: false, ...options });\n }\n\n static formatBindParameters(sql, values, dialect) {\n const bindParam = [];\n const replacementFunc = (match, key, values_) => {\n if (values_[key] !== undefined) {\n bindParam.push(values_[key]);\n return '?';\n }\n return undefined;\n };\n sql = AbstractQuery.formatBindParameters(sql, values, dialect, replacementFunc)[0];\n return [sql, bindParam.length > 0 ? bindParam : undefined];\n }\n\n async run(sql, parameters) {\n this.sql = sql;\n const { connection, options } = this;\n\n const showWarnings = this.sequelize.options.showWarnings || options.showWarnings;\n\n const complete = this._logQuery(sql, debug, parameters);\n\n if (parameters) {\n debug('parameters(%j)', parameters);\n }\n\n let results;\n const errForStack = new Error();\n\n try {\n if (parameters && parameters.length) {\n results = await new Promise((resolve, reject) => {\n connection\n .execute(sql, parameters, (error, result) => error ? reject(error) : resolve(result))\n .setMaxListeners(100);\n });\n } else {\n results = await new Promise((resolve, reject) => {\n connection\n .query({ sql }, (error, result) => error ? reject(error) : resolve(result))\n .setMaxListeners(100);\n });\n }\n } catch (error) {\n if (options.transaction && error.errno === ER_DEADLOCK) {\n // MySQL automatically rolls-back transactions in the event of a deadlock.\n // However, we still initiate a manual rollback to ensure the connection gets released - see #13102.\n try {\n await options.transaction.rollback();\n } catch (error_) {\n // Ignore errors - since MySQL automatically rolled back, we're\n // not that worried about this redundant rollback failing.\n }\n\n options.transaction.finished = 'rollback';\n }\n\n error.sql = sql;\n error.parameters = parameters;\n throw this.formatError(error, errForStack.stack);\n } finally {\n complete();\n }\n\n if (showWarnings && results && results.warningStatus > 0) {\n await this.logWarnings(results);\n }\n return this.formatResults(results);\n }\n\n /**\n * High level function that handles the results of a query execution.\n *\n *\n * Example:\n * query.formatResults([\n * {\n * id: 1, // this is from the main table\n * attr2: 'snafu', // this is from the main table\n * Tasks.id: 1, // this is from the associated table\n * Tasks.title: 'task' // this is from the associated table\n * }\n * ])\n *\n * @param {Array} data - The result of the query execution.\n * @private\n */\n formatResults(data) {\n let result = this.instance;\n\n if (this.isInsertQuery(data)) {\n this.handleInsertQuery(data);\n\n if (!this.instance) {\n // handle bulkCreate AI primary key\n if (\n data.constructor.name === 'ResultSetHeader'\n && this.model\n && this.model.autoIncrementAttribute\n && this.model.autoIncrementAttribute === this.model.primaryKeyAttribute\n && this.model.rawAttributes[this.model.primaryKeyAttribute]\n ) {\n const startId = data[this.getInsertIdField()];\n result = [];\n for (let i = startId; i < startId + data.affectedRows; i++) {\n result.push({ [this.model.rawAttributes[th
"mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,gBAAgB,QAAQ;AAC9B,MAAM,kBAAkB,QAAQ;AAChC,MAAM,IAAI,QAAQ;AAClB,MAAM,EAAE,WAAW,QAAQ;AAE3B,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAE7B,MAAM,QAAQ,OAAO,aAAa;AAElC,oBAAoB,cAAc;AAAA,EAChC,YAAY,YAAY,WAAW,SAAS;AAC1C,UAAM,YAAY,WAAW,iBAAE,cAAc,SAAU;AAAA;AAAA,SAGlD,qBAAqB,KAAK,QAAQ,SAAS;AAChD,UAAM,YAAY;AAClB,UAAM,kBAAkB,CAAC,OAAO,KAAK,YAAY;AAC/C,UAAI,QAAQ,SAAS,QAAW;AAC9B,kBAAU,KAAK,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