API/api.medcify.app/node_modules/sequelize/lib/dialects/db2/query-generator.js.map
2022-09-26 11:41:44 +05:30

8 lines
44 KiB
Plaintext

{
"version": 3,
"sources": ["../../../src/dialects/db2/query-generator.js"],
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\nconst Utils = require('../../utils');\nconst DataTypes = require('../../data-types');\nconst AbstractQueryGenerator = require('../abstract/query-generator');\nconst randomBytes = require('crypto').randomBytes;\nconst Op = require('../../operators');\n\n/* istanbul ignore next */\nconst throwMethodUndefined = function(methodName) {\n throw new Error(`The method \"${methodName}\" is not defined! Please add it to your sql dialect.`);\n};\n\nclass Db2QueryGenerator extends AbstractQueryGenerator {\n constructor(options) {\n super(options);\n\n this.OperatorMap = { ...this.OperatorMap, [Op.regexp]: 'REGEXP_LIKE',\n [Op.notRegexp]: 'NOT REGEXP_LIKE' };\n this.autoGenValue = 1;\n }\n\n createSchema(schema) {\n return [\n 'CREATE SCHEMA',\n this.quoteIdentifier(schema),\n ';'\n ].join(' ');\n }\n\n dropSchema(schema) {\n // DROP SCHEMA Can't drop schema if it is not empty.\n // DROP SCHEMA Can't drop objects belonging to the schema\n // So, call the admin procedure to drop schema.\n const query = `CALL SYSPROC.ADMIN_DROP_SCHEMA(${ wrapSingleQuote(schema.trim()) }, NULL, ? , ?)`;\n const sql = { query };\n sql.bind = [{ ParamType: 'INOUT', Data: 'ERRORSCHEMA' },\n { ParamType: 'INOUT', Data: 'ERRORTABLE' }];\n return sql;\n }\n\n showSchemasQuery() {\n return 'SELECT SCHEMANAME AS \"schema_name\" FROM SYSCAT.SCHEMATA WHERE ' +\n \"(SCHEMANAME NOT LIKE 'SYS%') AND SCHEMANAME NOT IN ('NULLID', 'SQLJ', 'ERRORSCHEMA')\";\n }\n\n\n\n versionQuery() {\n return 'select service_level as VERSION from TABLE (sysproc.env_get_inst_info()) as A';\n }\n\n createTableQuery(tableName, attributes, options) {\n const query = 'CREATE TABLE <%= table %> (<%= attributes %>)',\n primaryKeys = [],\n foreignKeys = {},\n attrStr = [],\n commentTemplate = ' -- <%= comment %>, ' +\n 'TableName = <%= table %>, ColumnName = <%= column %>;';\n\n let commentStr = '';\n\n for (const attr in attributes) {\n if (Object.prototype.hasOwnProperty.call(attributes, attr)) {\n let dataType = attributes[attr];\n let match;\n\n if (dataType.includes('COMMENT ')) {\n const commentMatch = dataType.match(/^(.+) (COMMENT.*)$/);\n if (commentMatch && commentMatch.length > 2) {\n const commentText = commentMatch[2].replace(/COMMENT/, '').trim();\n commentStr += _.template(commentTemplate, this._templateSettings)({\n table: this.quoteIdentifier(tableName),\n comment: this.escape(commentText),\n column: this.quoteIdentifier(attr)\n });\n // remove comment related substring from dataType\n dataType = commentMatch[1];\n }\n }\n\n if (_.includes(dataType, 'PRIMARY KEY')) {\n primaryKeys.push(attr);\n\n if (_.includes(dataType, 'REFERENCES')) {\n // Db2 doesn't support inline REFERENCES declarations: move to the end\n match = dataType.match(/^(.+) (REFERENCES.*)$/);\n attrStr.push(`${ this.quoteIdentifier(attr) } ${ match[1].replace(/PRIMARY KEY/, '') }`);\n foreignKeys[attr] = match[2];\n } else {\n attrStr.push(`${ this.quoteIdentifier(attr) } ${ dataType.replace(/PRIMARY KEY/, '') }`);\n }\n } else if (_.includes(dataType, 'REFERENCES')) {\n // Db2 doesn't support inline REFERENCES declarations: move to the end\n match = dataType.match(/^(.+) (REFERENCES.*)$/);\n attrStr.push(`${this.quoteIdentifier(attr)} ${match[1]}`);\n foreignKeys[attr] = match[2];\n } else {\n if (options && options.uniqueKeys) {\n for (const ukey in options.uniqueKeys) {\n if (options.uniqueKeys[ukey].fields.includes(attr) &&\n ! _.includes(dataType, 'NOT NULL'))\n {\n dataType += ' NOT NULL';\n break;\n }\n }\n }\n attrStr.push(`${this.quoteIdentifier(attr)} ${dataType}`);\n }\n\n }\n }\n\n const values = {\n table: this.quoteTable(tableName),\n attributes: attrStr.join(', ')\n },\n pkString = primaryKeys.map(pk => { return this.quoteIdentifier(pk); }).join(', ');\n\n if (options && options.uniqueKeys) {\n _.each(options.uniqueKeys, (columns, indexName) => {\n if (columns.customIndex) {\n if (!_.isString(indexName)) {\n indexName = `uniq_${ tableName }_${ columns.fields.join('_')}`;\n }\n values.attributes += `, CONSTRAINT ${this.quoteIdentifier(indexName)} UNIQUE (${columns.fields.map(field => this.quoteIdentifier(field)).join(', ')})`;\n }\n });\n }\n\n if (pkString.length > 0) {\n values.attributes += `, PRIMARY KEY (${pkString})`;\n }\n\n for (const fkey in foreignKeys) {\n if (Object.prototype.hasOwnProperty.call(foreignKeys, fkey)) {\n values.attributes += `, FOREIGN KEY (${ this.quoteIdentifier(fkey) }) ${ foreignKeys[fkey] }`;\n }\n }\n return `${_.template(query, this._templateSettings)(values).trim() };${ commentStr}`;\n }\n\n\n describeTableQuery(tableName, schema) {\n let sql = [\n 'SELECT NAME AS \"Name\", TBNAME AS \"Table\", TBCREATOR AS \"Schema\",',\n 'TRIM(COLTYPE) AS \"Type\", LENGTH AS \"Length\", SCALE AS \"Scale\",',\n 'NULLS AS \"IsNull\", DEFAULT AS \"Default\", COLNO AS \"Colno\",',\n 'IDENTITY AS \"IsIdentity\", KEYSEQ AS \"KeySeq\", REMARKS AS \"Comment\"',\n 'FROM',\n 'SYSIBM.SYSCOLUMNS',\n 'WHERE TBNAME =', wrapSingleQuote(tableName)\n ].join(' ');\n\n if (schema) {\n sql += ` AND TBCREATOR =${wrapSingleQuote(schema)}`;\n } else {\n sql += ' AND TBCREATOR = USER';\n }\n\n return `${sql};`;\n }\n\n renameTableQuery(before, after) {\n const query = 'RENAME TABLE <%= before %> TO <%= after %>;';\n return _.template(query, this._templateSettings)({\n before: this.quoteTable(before),\n after: this.quoteTable(after)\n });\n }\n\n showTablesQuery() {\n return \"SELECT TABNAME AS \\\"tableName\\\", TRIM(TABSCHEMA) AS \\\"tableSchema\\\" FROM SYSCAT.TABLES WHERE TABSCHEMA = USER AND TYPE = 'T' ORDER BY TABSCHEMA, TABNAME\";\n }\n\n tableExistsQuery(table) {\n const tableName = table.tableName || table;\n // The default schema is the authorization ID of the owner of the plan or package.\n // https://www.ibm.com/docs/en/db2-for-zos/12?topic=concepts-db2-schemas-schema-qualifiers\n const schemaName = table.schema || this.sequelize.config.username.toUpperCase();\n\n // https://www.ibm.com/docs/en/db2-for-zos/11?topic=tables-systables\n return `SELECT name FROM sysibm.systables WHERE NAME = ${wrapSingleQuote(tableName)} AND CREATOR = ${wrapSingleQuote(schemaName)}`;\n }\n\n dropTableQuery(tableName) {\n const query = 'DROP TABLE <%= table %>';\n const values = {\n table: this.quoteTable(tableName)\n };\n\n return `${_.template(query, this._templateSettings)(values).trim()};`;\n }\n\n addColumnQuery(table, key, dataType) {\n dataType.field = key;\n\n const query = 'ALTER TABLE <%= table %> ADD <%= attribute %>;',\n attribute = _.template('<%= key %> <%= definition %>', this._templateSettings)({\n key: this.quoteIdentifier(key),\n definition: this.attributeToSQL(dataType, {\n context: 'addColumn'\n })\n });\n\n return _.template(query, this._templateSettings)({\n table: this.quoteTable(table),\n attribute\n });\n }\n\n removeColumnQuery(tableName, attributeName) {\n const query = 'ALTER TABLE <%= tableName %> DROP COLUMN <%= attributeName %>;';\n return _.template(query, this._templateSettings)({\n tableName: this.quoteTable(tableName),\n attributeName: this.quoteIdentifier(attributeName)\n });\n }\n\n changeColumnQuery(tableName, attributes) {\n const query = 'ALTER TABLE <%= tableName %> <%= query %>;';\n const attrString = [],\n constraintString = [];\n\n for (const attributeName in attributes) {\n const attrValue = attributes[attributeName];\n let defs = [attrValue];\n if (Array.isArray(attrValue)) {\n defs = attrValue;\n }\n for (let i = 0; i < defs.length; i++) {\n const definition = defs[i];\n if (definition.match(/REFERENCES/)) {\n constraintString.push(_.template('<%= fkName %> FOREIGN KEY (<%= attrName %>) <%= definition %>', this._templateSettings)({\n fkName: this.quoteIdentifier(`${attributeName}_foreign_idx`),\n attrName: this.quoteIdentifier(attributeName),\n definition: definition.replace(/.+?(?=REFERENCES)/, '')\n }));\n } else if (_.startsWith(definition, 'DROP ')) {\n attrString.push(_.template('<%= attrName %> <%= definition %>', this._templateSettings)({\n attrName: this.quoteIdentifier(attributeName),\n definition\n }));\n } else {\n attrString.push(_.template('<%= attrName %> SET <%= definition %>', this._templateSettings)({\n attrName: this.quoteIdentifier(attributeName),\n definition\n }));\n }\n }\n }\n\n let finalQuery = '';\n if (attrString.length) {\n finalQuery += `ALTER COLUMN ${attrString.join(' ALTER COLUMN ')}`;\n finalQuery += constraintString.length ? ' ' : '';\n }\n if (constraintString.length) {\n finalQuery += `ADD CONSTRAINT ${constraintString.join(' ADD CONSTRAINT ')}`;\n }\n\n return _.template(query, this._templateSettings)({\n tableName: this.quoteTable(tableName),\n query: finalQuery\n });\n }\n\n renameColumnQuery(tableName, attrBefore, attributes) {\n const query = 'ALTER TABLE <%= tableName %> RENAME COLUMN <%= before %> TO <%= after %>;',\n newName = Object.keys(attributes)[0];\n\n return _.template(query, this._templateSettings)({\n tableName: this.quoteTable(tableName),\n before: this.quoteIdentifier(attrBefore),\n after: this.quoteIdentifier(newName)\n });\n }\n\n addConstraintQuery(tableName, options) {\n options = options || {};\n if (options.onUpdate && options.onUpdate.toUpperCase() === 'CASCADE') {\n // Db2 does not support ON UPDATE CASCADE, remove it.\n delete options.onUpdate;\n }\n const constraintSnippet = this.getConstraintSnippet(tableName, options);\n\n if (typeof tableName === 'string') {\n tableName = this.quoteIdentifiers(tableName);\n } else {\n tableName = this.quoteTable(tableName);\n }\n\n return `ALTER TABLE ${tableName} ADD ${constraintSnippet};`;\n }\n\n bulkInsertQuery(tableName, attrValueHashes, options, attributes) {\n options = options || {};\n attributes = attributes || {};\n let query = 'INSERT INTO <%= table %> (<%= attributes %>)<%= output %> VALUES <%= tuples %>;';\n if (options.returning) {\n query = 'SELECT * FROM FINAL TABLE( INSERT INTO <%= table %> (<%= attributes %>)<%= output %> VALUES <%= tuples %>);';\n }\n const emptyQuery = 'INSERT INTO <%= table %>',\n tuples = [],\n allAttributes = [],\n allQueries = [];\n\n let outputFragment;\n const valuesForEmptyQuery = [];\n\n if (options.returning) {\n outputFragment = '';\n }\n _.forEach(attrValueHashes, attrValueHash => {\n // special case for empty objects with primary keys\n const fields = Object.keys(attrValueHash);\n const firstAttr = attributes[fields[0]];\n if (fields.length === 1 && firstAttr && firstAttr.autoIncrement && attrValueHash[fields[0]] === null) {\n valuesForEmptyQuery.push(`(${ this.autoGenValue++ })`);\n return;\n }\n\n // normal case\n _.forOwn(attrValueHash, (value, key) => {\n if (allAttributes.indexOf(key) === -1) {\n if (value === null && attributes[key] && attributes[key].autoIncrement)\n return;\n\n allAttributes.push(key);\n }\n });\n });\n if (valuesForEmptyQuery.length > 0) {\n allQueries.push(`${emptyQuery } VALUES ${ valuesForEmptyQuery.join(',')}`);\n }\n\t\n if (allAttributes.length > 0) {\n _.forEach(attrValueHashes, attrValueHash => {\n tuples.push(`(${\n allAttributes.map(key =>\n this.escape(attrValueHash[key]), undefined, { context: 'INSERT' }).join(',')})`);\n });\n allQueries.push(query);\n }\n const replacements = {\n table: this.quoteTable(tableName),\n attributes: allAttributes.map(attr =>\n this.quoteIdentifier(attr)).join(','),\n tuples,\n output: outputFragment\n };\n\n const generatedQuery = _.template(allQueries.join(';'), this._templateSettings)(replacements);\n return generatedQuery;\n }\n\n updateQuery(tableName, attrValueHash, where, options, attributes) {\n const sql = super.updateQuery(tableName, attrValueHash, where, options, attributes);\n options = options || {};\n _.defaults(options, this.options);\n if ( ! options.limit ) {\n sql.query = `SELECT * FROM FINAL TABLE (${ sql.query });`;\n return sql;\n }\n\n attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, options.omitNull, options);\n\n const modelAttributeMap = {};\n const values = [];\n const bind = [];\n const bindParam = options.bindParam || this.bindParam(bind);\n\n if (attributes) {\n _.each(attributes, (attribute, key) => {\n modelAttributeMap[key] = attribute;\n if (attribute.field) {\n modelAttributeMap[attribute.field] = attribute;\n }\n });\n }\n\n for (const key in attrValueHash) {\n const value = attrValueHash[key];\n\n if (value instanceof Utils.SequelizeMethod || options.bindParam === false)\n {\n values.push(`${this.quoteIdentifier(key) }=${ this.escape(value, modelAttributeMap && modelAttributeMap[key] || undefined, { context: 'UPDATE' })}`);\n } else {\n values.push(`${this.quoteIdentifier(key) }=${ this.format(value, modelAttributeMap && modelAttributeMap[key] || undefined, { context: 'UPDATE' }, bindParam)}`);\n }\n }\n\n let query;\n const whereOptions = _.defaults({ bindParam }, options);\n\n query = `UPDATE (SELECT * FROM ${this.quoteTable(tableName)} ${this.whereQuery(where, whereOptions)} FETCH NEXT ${this.escape(options.limit)} ROWS ONLY) SET ${values.join(',')}`;\n query = `SELECT * FROM FINAL TABLE (${ query });`;\n return { query, bind };\n }\n\n upsertQuery(tableName, insertValues, updateValues, where, model) {\n const targetTableAlias = this.quoteTable(`${tableName}_target`);\n const sourceTableAlias = this.quoteTable(`${tableName}_source`);\n const primaryKeysAttrs = [];\n const identityAttrs = [];\n const uniqueAttrs = [];\n const tableNameQuoted = this.quoteTable(tableName);\n\n //Obtain primaryKeys, uniquekeys and identity attrs from rawAttributes as model is not passed\n for (const key in model.rawAttributes) {\n if (model.rawAttributes[key].primaryKey) {\n primaryKeysAttrs.push(model.rawAttributes[key].field || key);\n }\n if (model.rawAttributes[key].unique) {\n uniqueAttrs.push(model.rawAttributes[key].field || key);\n }\n if (model.rawAttributes[key].autoIncrement) {\n identityAttrs.push(model.rawAttributes[key].field || key);\n }\n }\n\n //Add unique indexes defined by indexes option to uniqueAttrs\n for (const index of model._indexes) {\n if (index.unique && index.fields) {\n for (const field of index.fields) {\n const fieldName = typeof field === 'string' ? field : field.name || field.attribute;\n if (uniqueAttrs.indexOf(fieldName) === -1 && model.rawAttributes[fieldName]) {\n uniqueAttrs.push(fieldName);\n }\n }\n }\n }\n\n const updateKeys = Object.keys(updateValues);\n const insertKeys = Object.keys(insertValues);\n const insertKeysQuoted = insertKeys.map(key => this.quoteIdentifier(key)).join(', ');\n const insertValuesEscaped = insertKeys.map(key => this.escape(insertValues[key])).join(', ');\n const sourceTableQuery = `VALUES(${insertValuesEscaped})`; //Virtual Table\n let joinCondition;\n\n //Filter NULL Clauses\n const clauses = where[Op.or].filter(clause => {\n let valid = true;\n /*\n * Exclude NULL Composite PK/UK. Partial Composite clauses should also be excluded as it doesn't guarantee a single row\n */\n for (const key in clause) {\n if (!clause[key]) {\n valid = false;\n break;\n }\n }\n return valid;\n });\n\n /*\n * Generate ON condition using PK(s).\n * If not, generate using UK(s). Else throw error\n */\n const getJoinSnippet = array => {\n return array.map(key => {\n key = this.quoteIdentifier(key);\n return `${targetTableAlias}.${key} = ${sourceTableAlias}.${key}`;\n });\n };\n\n if (clauses.length === 0) {\n throw new Error('Primary Key or Unique key should be passed to upsert query');\n } else {\n // Search for primary key attribute in clauses -- Model can have two separate unique keys\n for (const key in clauses) {\n const keys = Object.keys(clauses[key]);\n if (primaryKeysAttrs.indexOf(keys[0]) !== -1) {\n joinCondition = getJoinSnippet(primaryKeysAttrs).join(' AND ');\n break;\n }\n }\n if (!joinCondition) {\n joinCondition = getJoinSnippet(uniqueAttrs).join(' AND ');\n }\n }\n\n // Remove the IDENTITY_INSERT Column from update\n const filteredUpdateClauses = updateKeys.filter(key => {\n if (identityAttrs.indexOf(key) === -1) {\n return true;\n }\n return false;\n })\n .map(key => {\n const value = this.escape(updateValues[key]);\n key = this.quoteIdentifier(key);\n return `${targetTableAlias}.${key} = ${value}`;\n }).join(', ');\n const updateSnippet = filteredUpdateClauses.length > 0 ? `WHEN MATCHED THEN UPDATE SET ${filteredUpdateClauses}` : '';\n\t\n const insertSnippet = `(${insertKeysQuoted}) VALUES(${insertValuesEscaped})`;\n\t\n let query = `MERGE INTO ${tableNameQuoted} AS ${targetTableAlias} USING (${sourceTableQuery}) AS ${sourceTableAlias}(${insertKeysQuoted}) ON ${joinCondition}`;\n query += ` ${updateSnippet} WHEN NOT MATCHED THEN INSERT ${insertSnippet};`;\n return query;\n }\n\n truncateTableQuery(tableName) {\n return `TRUNCATE TABLE ${this.quoteTable(tableName)} IMMEDIATE`;\n }\n\n deleteQuery(tableName, where, options = {}, model) {\n const table = this.quoteTable(tableName);\n const query = 'DELETE FROM <%= table %><%= where %><%= limit %>';\n\n where = this.getWhereConditions(where, null, model, options);\n\n let limit = '';\n\n if (options.offset > 0) {\n limit = ` OFFSET ${ this.escape(options.offset) } ROWS`;\n }\n if (options.limit) {\n limit += ` FETCH NEXT ${ this.escape(options.limit) } ROWS ONLY`;\n }\n\n const replacements = {\n limit,\n table,\n where\n };\n\n if (replacements.where) {\n replacements.where = ` WHERE ${replacements.where}`;\n }\n\n return _.template(query, this._templateSettings)(replacements);\n }\n\n showIndexesQuery(tableName) {\n let sql = 'SELECT NAME AS \"name\", TBNAME AS \"tableName\", UNIQUERULE AS \"keyType\", COLNAMES, INDEXTYPE AS \"type\" FROM SYSIBM.SYSINDEXES WHERE TBNAME = <%= tableName %>';\n let schema = undefined;\n if (_.isObject(tableName)) {\n schema = tableName.schema;\n tableName = tableName.tableName;\n }\n if (schema) {\n sql = `${sql} AND TBCREATOR = <%= schemaName %>`;\n }\n sql = `${sql} ORDER BY NAME;`;\n return _.template(sql, this._templateSettings)({\n tableName: wrapSingleQuote(tableName),\n schemaName: wrapSingleQuote(schema)\n });\n }\n\n showConstraintsQuery(tableName, constraintName) {\n let sql = `SELECT CONSTNAME AS \"constraintName\", TRIM(TABSCHEMA) AS \"schemaName\", TABNAME AS \"tableName\" FROM SYSCAT.TABCONST WHERE TABNAME = '${tableName}'`;\n\n if (constraintName) {\n sql += ` AND CONSTNAME LIKE '%${constraintName}%'`;\n }\n\n return `${sql } ORDER BY CONSTNAME;`;\n }\n\n removeIndexQuery(tableName, indexNameOrAttributes) {\n const sql = 'DROP INDEX <%= indexName %>';\n let indexName = indexNameOrAttributes;\n\n if (typeof indexName !== 'string') {\n indexName = Utils.underscore(`${tableName}_${indexNameOrAttributes.join('_')}`);\n }\n\n const values = {\n tableName: this.quoteIdentifiers(tableName),\n indexName: this.quoteIdentifiers(indexName)\n };\n\n return _.template(sql, this._templateSettings)(values);\n }\n\n attributeToSQL(attribute, options) {\n if (!_.isPlainObject(attribute)) {\n attribute = {\n type: attribute\n };\n }\n\n let template;\n let changeNull = 1;\n\n if (attribute.type instanceof DataTypes.ENUM) {\n if (attribute.type.values && !attribute.values) attribute.values = attribute.type.values;\n\n // enums are a special case\n template = attribute.type.toSql();\n template += ` CHECK (${this.quoteIdentifier(attribute.field)} IN(${attribute.values.map(value => {\n return this.escape(value);\n }).join(', ') }))`;\n } else {\n template = attribute.type.toString();\n }\n\n if (options && options.context === 'changeColumn' && attribute.type) {\n template = `DATA TYPE ${template}`;\n }\n else if (attribute.allowNull === false || attribute.primaryKey === true ||\n attribute.unique) {\n template += ' NOT NULL';\n changeNull = 0;\n }\n\n if (attribute.autoIncrement) {\n let initialValue = 1;\n if (attribute.initialAutoIncrement) {\n initialValue = attribute.initialAutoIncrement;\n }\n template += ` GENERATED BY DEFAULT AS IDENTITY(START WITH ${initialValue}, INCREMENT BY 1)`;\n }\n\n // Blobs/texts cannot have a defaultValue\n if (attribute.type !== 'TEXT' && attribute.type._binary !== true &&\n Utils.defaultValueSchemable(attribute.defaultValue)) {\n template += ` DEFAULT ${this.escape(attribute.defaultValue)}`;\n }\n\n if (attribute.unique === true) {\n template += ' UNIQUE';\n }\n\n if (attribute.primaryKey) {\n template += ' PRIMARY KEY';\n }\n\n if ((!options || !options.withoutForeignKeyConstraints) && attribute.references) {\n if (options && options.context === 'addColumn' && options.foreignKey) {\n const attrName = this.quoteIdentifier(options.foreignKey);\n const fkName = `${options.tableName }_${ attrName }_fidx`;\n template += `, CONSTRAINT ${ fkName } FOREIGN KEY (${ attrName })`;\n }\n template += ` REFERENCES ${this.quoteTable(attribute.references.model)}`;\n\n if (attribute.references.key) {\n template += ` (${ this.quoteIdentifier(attribute.references.key) })`;\n } else {\n template += ` (${ this.quoteIdentifier('id') })`;\n }\n\n if (attribute.onDelete) {\n template += ` ON DELETE ${ attribute.onDelete.toUpperCase()}`;\n }\n\n if (attribute.onUpdate && attribute.onUpdate.toUpperCase() != 'CASCADE') {\n // Db2 do not support CASCADE option for ON UPDATE clause.\n template += ` ON UPDATE ${ attribute.onUpdate.toUpperCase()}`;\n }\n }\n\n if (options && options.context === 'changeColumn' && changeNull === 1 &&\n attribute.allowNull !== undefined) {\n template = [template];\n if (attribute.allowNull) {\n template.push('DROP NOT NULL');\n } else {\n template.push('NOT NULL');\n }\n }\n\n if (attribute.comment && typeof attribute.comment === 'string') {\n template += ` COMMENT ${attribute.comment}`;\n }\n\n return template;\n }\n\n attributesToSQL(attributes, options) {\n const result = {},\n existingConstraints = [];\n let key,\n attribute;\n\n for (key in attributes) {\n attribute = attributes[key];\n\n if (attribute.references) {\n\n if (existingConstraints.indexOf(attribute.references.model.toString()) !== -1) {\n // no cascading constraints to a table more than once\n attribute.onDelete = '';\n attribute.onUpdate = '';\n } else if (attribute.unique && attribute.unique === true) {\n attribute.onDelete = '';\n attribute.onUpdate = '';\n } else {\n existingConstraints.push(attribute.references.model.toString());\n }\n }\n\n if (key && !attribute.field && typeof attribute === 'object') attribute.field = key;\n result[attribute.field || key] = this.attributeToSQL(attribute, options);\n }\n\n return result;\n }\n\n createTrigger() {\n throwMethodUndefined('createTrigger');\n }\n\n dropTrigger() {\n throwMethodUndefined('dropTrigger');\n }\n\n renameTrigger() {\n throwMethodUndefined('renameTrigger');\n }\n\n createFunction() {\n throwMethodUndefined('createFunction');\n }\n\n dropFunction() {\n throwMethodUndefined('dropFunction');\n }\n\n renameFunction() {\n throwMethodUndefined('renameFunction');\n }\n\n /**\n * Generate SQL for ForeignKeysQuery.\n *\n * @param {string} condition The condition string for query.\n * @returns {string}\n */\n _getForeignKeysQuerySQL(condition) {\n return 'SELECT R.CONSTNAME AS \"constraintName\", ' +\n 'TRIM(R.TABSCHEMA) AS \"constraintSchema\", ' +\n 'R.TABNAME AS \"tableName\", ' +\n 'TRIM(R.TABSCHEMA) AS \"tableSchema\", LISTAGG(C.COLNAME,\\', \\') ' +\n 'WITHIN GROUP (ORDER BY C.COLNAME) AS \"columnName\", ' +\n 'TRIM(R.REFTABSCHEMA) AS \"referencedTableSchema\", ' +\n 'R.REFTABNAME AS \"referencedTableName\", ' +\n 'TRIM(R.PK_COLNAMES) AS \"referencedColumnName\" ' +\n 'FROM SYSCAT.REFERENCES R, SYSCAT.KEYCOLUSE C ' +\n 'WHERE R.CONSTNAME = C.CONSTNAME AND R.TABSCHEMA = C.TABSCHEMA ' +\n `AND R.TABNAME = C.TABNAME${ condition } GROUP BY R.REFTABSCHEMA, ` +\n 'R.REFTABNAME, R.TABSCHEMA, R.TABNAME, R.CONSTNAME, R.PK_COLNAMES';\n }\n\n /**\n * Generates an SQL query that returns all foreign keys of a table.\n *\n * @param {Stirng|object} table The name of the table.\n * @param {string} schemaName The name of the schema. \n * @returns {string} The generated sql query.\n */\n getForeignKeysQuery(table, schemaName) {\n const tableName = table.tableName || table;\n schemaName = table.schema || schemaName;\n let sql = '';\n if (tableName) {\n sql = ` AND R.TABNAME = ${wrapSingleQuote(tableName)}`;\n }\n if (schemaName) {\n sql += ` AND R.TABSCHEMA = ${wrapSingleQuote(schemaName)}`;\n }\n return this._getForeignKeysQuerySQL(sql);\n }\n\n getForeignKeyQuery(table, columnName) {\n const tableName = table.tableName || table;\n const schemaName = table.schema;\n let sql = '';\n if (tableName) {\n sql = ` AND R.TABNAME = ${wrapSingleQuote(tableName)}`;\n }\n if (schemaName) {\n sql += ` AND R.TABSCHEMA = ${wrapSingleQuote(schemaName)}`;\n }\n if (columnName) {\n sql += ` AND C.COLNAME = ${wrapSingleQuote(columnName)}`;\n }\n return this._getForeignKeysQuerySQL(sql);\n }\n\n getPrimaryKeyConstraintQuery(table, attributeName) {\n const tableName = wrapSingleQuote(table.tableName || table);\n return [\n 'SELECT TABNAME AS \"tableName\",',\n 'COLNAME AS \"columnName\",',\n 'CONSTNAME AS \"constraintName\"',\n 'FROM SYSCAT.KEYCOLUSE WHERE CONSTNAME LIKE \\'PK_%\\'',\n `AND COLNAME = ${wrapSingleQuote(attributeName)}`,\n `AND TABNAME = ${tableName};`\n ].join(' ');\n }\n\n dropForeignKeyQuery(tableName, foreignKey) {\n return _.template('ALTER TABLE <%= table %> DROP <%= key %>', this._templateSettings)({\n table: this.quoteTable(tableName),\n key: this.quoteIdentifier(foreignKey)\n });\n }\n\n dropConstraintQuery(tableName, constraintName) {\n const sql = 'ALTER TABLE <%= table %> DROP CONSTRAINT <%= constraint %>;';\n return _.template(sql, this._templateSettings)({\n table: this.quoteTable(tableName),\n constraint: this.quoteIdentifier(constraintName)\n });\n }\n\n setAutocommitQuery() {\n return '';\n }\n\n setIsolationLevelQuery() {\n\n }\n\n generateTransactionId() {\n return randomBytes(10).toString('hex');\n }\n\n startTransactionQuery(transaction) {\n if (transaction.parent) {\n return `SAVE TRANSACTION ${this.quoteIdentifier(transaction.name)};`;\n }\n\n return 'BEGIN TRANSACTION;';\n }\n\n commitTransactionQuery(transaction) {\n if (transaction.parent) {\n return;\n }\n\n return 'COMMIT TRANSACTION;';\n }\n\n rollbackTransactionQuery(transaction) {\n if (transaction.parent) {\n return `ROLLBACK TRANSACTION ${this.quoteIdentifier(transaction.name)};`;\n }\n\n return 'ROLLBACK TRANSACTION;';\n }\n\n addLimitAndOffset(options) {\n const offset = options.offset || 0;\n let fragment = '';\n\n if (offset > 0) {\n fragment += ` OFFSET ${ this.escape(offset) } ROWS`;\n }\n\n if (options.limit) {\n fragment += ` FETCH NEXT ${ this.escape(options.limit) } ROWS ONLY`;\n }\n\n return fragment;\n }\n\n booleanValue(value) {\n return value ? 1 : 0;\n }\n\n addUniqueFields(dataValues, rawAttributes, uniqno) {\n uniqno = uniqno === undefined ? 1 : uniqno;\n for (const key in rawAttributes) {\n if (rawAttributes[key].unique && dataValues[key] === undefined) {\n if (rawAttributes[key].type instanceof DataTypes.DATE) {\n dataValues[key] = Utils.now('db2');\n } else if (rawAttributes[key].type instanceof DataTypes.STRING) {\n dataValues[key] = `unique${uniqno++}`;\n } else if (rawAttributes[key].type instanceof DataTypes.INTEGER) {\n dataValues[key] = uniqno++;\n } else if (rawAttributes[key].type instanceof DataTypes.BOOLEAN) {\n dataValues[key] = new DataTypes.BOOLEAN(false);\n }\n }\n }\n return uniqno;\n }\n\n /**\n * Quote identifier in sql clause\n *\n * @param {string} identifier\n * @param {boolean} force\n *\n * @returns {string}\n */\n quoteIdentifier(identifier, force) {\n return Utils.addTicks(Utils.removeTicks(identifier, '\"'), '\"');\n }\n\n}\n\n// private methods\nfunction wrapSingleQuote(identifier) {\n if (identifier) {\n return `'${ identifier }'`;\n //return Utils.addTicks(\"'\"); // It removes quote from center too.\n }\n return '';\n}\n\nmodule.exports = Db2QueryGenerator;\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,QAAQ;AAClB,MAAM,QAAQ,QAAQ;AACtB,MAAM,YAAY,QAAQ;AAC1B,MAAM,yBAAyB,QAAQ;AACvC,MAAM,cAAc,QAAQ,UAAU;AACtC,MAAM,KAAK,QAAQ;AAGnB,MAAM,uBAAuB,SAAS,YAAY;AAChD,QAAM,IAAI,MAAM,eAAe;AAAA;AAGjC,gCAAgC,uBAAuB;AAAA,EACrD,YAAY,SAAS;AACnB,UAAM;AAEN,SAAK,cAAc,iCAAK,KAAK,cAAV;AAAA,OAAwB,GAAG,SAAS;AAAA,OACpD,GAAG,YAAY;AAAA;AAClB,SAAK,eAAe;AAAA;AAAA,EAGtB,aAAa,QAAQ;AACnB,WAAO;AAAA,MACL;AAAA,MACA,KAAK,gBAAgB;AAAA,MACrB;AAAA,MACA,KAAK;AAAA;AAAA,EAGT,WAAW,QAAQ;AAIjB,UAAM,QAAQ,kCAAmC,gBAAgB,OAAO;AACxE,UAAM,MAAM,EAAE;AACd,QAAI,OAAO;AAAA,MAAC,EAAE,WAAW,SAAS,MAAM;AAAA,MACtC,EAAE,WAAW,SAAS,MAAM;AAAA;AAC9B,WAAO;AAAA;AAAA,EAGT,mBAAmB;AACjB,WAAO;AAAA;AA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