You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 lines
34 KiB

{
"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 overri
"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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