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
152 KiB

{
"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) {
"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;AAC1B,MAAM,QAAQ,QAAQ;AACtB,MAAM,cAAc,QAAQ;AAC5B,MAAM,YAAY,QAAQ;AAC1B,MAAM,gBAAgB,QAAQ;AAC9B,MAAM,UAAU,QAAQ;AACxB,MAAM,KAAK,QAAQ;AACnB,MAAM,iBAAiB,QAAQ;AAC/B,MAAM,aAAa,QAAQ;AAQ3B,qBAAqB;AAAA,E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