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

{
"version": 3,
"sources": ["../../../src/dialects/oracle/query.js"],
"sourcesContent": ["// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved\n\n'use strict';\n\nconst AbstractQuery = require('../abstract/query');\nconst SequelizeErrors = require('../../errors');\nconst parserStore = require('../parserStore')('oracle');\nconst _ = require('lodash');\nconst Utils = require('../../utils');\nconst { logger } = require('../../utils/logger');\n\nconst debug = logger.debugContext('sql:oracle');\n\nexport class OracleQuery extends AbstractQuery {\n constructor(connection, sequelize, options) {\n super(connection, sequelize, options);\n this.options = _.extend(\n {\n logging: console.log,\n plain: false,\n raw: false\n },\n options || {}\n );\n\n this.checkLoggingOption();\n this.outFormat = options.outFormat || this.sequelize.connectionManager.lib.OBJECT;\n }\n\n getInsertIdField() {\n return 'id';\n }\n\n getExecOptions() {\n const execOpts = { outFormat: this.outFormat, autoCommit: this.autoCommit };\n\n // We set the oracledb\n const oracledb = this.sequelize.connectionManager.lib;\n\n if (this.isSelectQuery() && this.model) {\n const fInfo = {};\n const keys = Object.keys(this.model.tableAttributes);\n for (const key of keys) {\n const keyValue = this.model.tableAttributes[key];\n if (keyValue.type.key === 'DECIMAL') {\n fInfo[key] = { type: oracledb.STRING };\n }\n // Fetching BIGINT as string since, node-oracledb doesn't support JS BIGINT yet\n if (keyValue.type.key === 'BIGINT') {\n fInfo[key] = { type: oracledb.STRING };\n }\n }\n if ( fInfo ) {\n execOpts.fetchInfo = fInfo;\n }\n }\n return execOpts;\n }\n async run(sql, parameters) {\n // We set the oracledb\n const oracledb = this.sequelize.connectionManager.lib;\n const complete = this._logQuery(sql, debug, parameters);\n const outParameters = [];\n const bindParameters = [];\n const bindDef = [];\n\n if (!sql.match(/END;$/)) {\n this.sql = sql.replace(/; *$/, '');\n } else {\n this.sql = sql;\n }\n\n // When this.options.bindAttributes exists then it is an insertQuery/upsertQuery\n // So we insert the return bind direction and type\n if (this.options.outBindAttributes && (Array.isArray(parameters) || _.isPlainObject(parameters))) {\n outParameters.push(...Object.values(this.options.outBindAttributes));\n // For upsertQuery we need to push the bindDef for isUpdate\n if (this.isUpsertQuery()) {\n outParameters.push({ dir: oracledb.BIND_OUT });\n }\n }\n\n this.bindParameters = outParameters;\n // construct input binds from parameters for single row insert execute call\n // ex: [3, 4,...]\n if (Array.isArray(parameters) || _.isPlainObject(parameters)) {\n if (this.options.executeMany) {\n // Constructing BindDefs for ExecuteMany call\n // Building the bindDef for in and out binds\n bindDef.push(...Object.values(this.options.inbindAttributes));\n bindDef.push(...outParameters);\n this.bindParameters = parameters;\n } else {\n Object.values(parameters).forEach(value => {\n bindParameters.push(value);\n });\n bindParameters.push(...outParameters);\n Object.assign(this.bindParameters, bindParameters);\n }\n }\n\n // TRANSACTION SUPPORT\n if (this.sql.startsWith('BEGIN TRANSACTION')) {\n this.autocommit = false;\n return Promise.resolve();\n } \n if (this.sql.startsWith('SET AUTOCOMMIT ON')) {\n this.autocommit = true;\n return Promise.resolve();\n } \n if (this.sql.startsWith('SET AUTOCOMMIT OFF')) {\n this.autocommit = false;\n return Promise.resolve();\n } \n if (this.sql.startsWith('DECLARE x NUMBER')) {\n // Calling a stored procedure for bulkInsert with NO attributes, returns nothing\n if (this.autoCommit === undefined) {\n if (this.connection.uuid) {\n this.autoCommit = false;\n
"mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAIA,MAAM,gBAAgB,QAAQ;AAC9B,MAAM,kBAAkB,QAAQ;AAChC,MAAM,cAAc,QAAQ,kBAAkB;AAC9C,MAAM,IAAI,QAAQ;AAClB,MAAM,QAAQ,QAAQ;AACtB,MAAM,EAAE,WAAW,QAAQ;AAE3B,MAAM,QAAQ,OAAO,aAAa;AAE3B,0BAA0B,cAAc;AAAA,EAC7C,YAAY,YAAY,WAAW,SAAS;AAC1C,UAAM,YAAY,WAAW;AAC7B,SAAK,UAAU,EAAE,OACf;AAAA,MACE,SAAS,QAAQ;AAAA,MACj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