(sql, parameters)
| 86 | } |
| 87 | |
| 88 | async run(sql, parameters) { |
| 89 | // We set the oracledb |
| 90 | const oracledb = this.sequelize.connectionManager.lib; |
| 91 | const complete = this._logQuery(sql, debug, parameters); |
| 92 | const outParameters = []; |
| 93 | const bindParameters = []; |
| 94 | const bindDef = []; |
| 95 | |
| 96 | if (!sql.match(/END;$/)) { |
| 97 | this.sql = sql.replace(/; *$/, ''); |
| 98 | } else { |
| 99 | this.sql = sql; |
| 100 | } |
| 101 | |
| 102 | // When this.options.bindAttributes exists then it is an insertQuery/upsertQuery |
| 103 | // So we insert the return bind direction and type |
| 104 | if (this.options.outBindAttributes && (Array.isArray(parameters) || _.isPlainObject(parameters))) { |
| 105 | this._convertBindAttributes('outBindAttributes', oracledb); |
| 106 | outParameters.push(...Object.values(this.options.outBindAttributes)); |
| 107 | // For upsertQuery we need to push the bindDef for isUpdate |
| 108 | if (this.isUpsertQuery()) { |
| 109 | outParameters.push({ dir: oracledb.BIND_OUT }); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | this.bindParameters = outParameters; |
| 114 | // construct input binds from parameters for single row insert execute call |
| 115 | // ex: [3, 4,...] |
| 116 | if (Array.isArray(parameters) || _.isPlainObject(parameters)) { |
| 117 | if (this.options.executeMany) { |
| 118 | // Constructing BindDefs for ExecuteMany call |
| 119 | // Building the bindDef for in and out binds |
| 120 | this._convertBindAttributes('inbindAttributes', oracledb); |
| 121 | bindDef.push(...Object.values(this.options.inbindAttributes)); |
| 122 | bindDef.push(...outParameters); |
| 123 | this.bindParameters = parameters; |
| 124 | } else if (this.isRawQuery()) { |
| 125 | this.bindParameters = parameters; |
| 126 | } else { |
| 127 | Object.values(parameters).forEach(value => { |
| 128 | bindParameters.push(value); |
| 129 | }); |
| 130 | bindParameters.push(...outParameters); |
| 131 | Object.assign(this.bindParameters, bindParameters); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // TRANSACTION SUPPORT |
| 136 | if (this.sql.startsWith('BEGIN TRANSACTION')) { |
| 137 | this.autocommit = false; |
| 138 | return Promise.resolve(); |
| 139 | } |
| 140 | if (this.sql.startsWith('SET AUTOCOMMIT ON')) { |
| 141 | this.autocommit = true; |
| 142 | return Promise.resolve(); |
| 143 | } |
| 144 | if (this.sql.startsWith('SET AUTOCOMMIT OFF')) { |
| 145 | this.autocommit = false; |
nothing calls this directly
no test coverage detected