MCPcopy Index your code
hub / github.com/sequelize/sequelize / run

Method run

src/dialects/oracle/query.js:88–249  ·  view source on GitHub ↗
(sql, parameters)

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 10

formatErrorMethod · 0.95
getExecOptionsMethod · 0.95
formatResultsMethod · 0.95
_logQueryMethod · 0.80
isUpsertQueryMethod · 0.80
isRawQueryMethod · 0.80
commitMethod · 0.80
rollbackMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected