MCPcopy
hub / github.com/sequelize/sequelize / run

Method run

lib/dialects/snowflake/query.js:29–79  ·  view source on GitHub ↗
(sql, parameters)

Source from the content-addressed store, hash-verified

27 }
28
29 async run(sql, parameters) {
30 this.sql = sql;
31 const { connection, options } = this;
32
33 const showWarnings = this.sequelize.options.showWarnings || options.showWarnings;
34
35 const complete = this._logQuery(sql, debug, parameters);
36
37 if (parameters) {
38 debug('parameters(%j)', parameters);
39 }
40
41 let results;
42
43 try {
44 results = await new Promise((resolve, reject) => {
45 connection.execute({
46 sqlText: sql,
47 binds: parameters,
48 complete(err, _stmt, rows) {
49 if (err) {
50 reject(err);
51 } else {
52 resolve(rows);
53 }
54 }
55 });
56 });
57 } catch (error) {
58 if (options.transaction && error.errno === ER_DEADLOCK) {
59 try {
60 await options.transaction.rollback();
61 } catch (error_) {
62 // ignore errors
63 }
64
65 options.transaction.finished = 'rollback';
66 }
67
68 error.sql = sql;
69 error.parameters = parameters;
70 throw this.formatError(error);
71 } finally {
72 complete();
73 }
74
75 if (showWarnings && results && results.warningStatus > 0) {
76 await this.logWarnings(results);
77 }
78 return this.formatResults(results);
79 }
80
81 /**
82 * High level function that handles the results of a query execution.

Callers 1

logWarningsMethod · 0.95

Calls 5

formatErrorMethod · 0.95
logWarningsMethod · 0.95
formatResultsMethod · 0.95
_logQueryMethod · 0.80
rollbackMethod · 0.80

Tested by

no test coverage detected