(sql, parameters)
| 32 | } |
| 33 | |
| 34 | async run(sql, parameters) { |
| 35 | this.sql = sql; |
| 36 | const { connection, options } = this; |
| 37 | |
| 38 | const showWarnings = this.sequelize.options.showWarnings || options.showWarnings; |
| 39 | |
| 40 | const complete = this._logQuery(sql, debug, parameters); |
| 41 | |
| 42 | if (parameters) { |
| 43 | debug('parameters(%j)', parameters); |
| 44 | } |
| 45 | |
| 46 | let results; |
| 47 | const errForStack = new Error(); |
| 48 | |
| 49 | try { |
| 50 | results = await connection.query(this.sql, parameters); |
| 51 | } catch (error) { |
| 52 | if (options.transaction && error.errno === ER_DEADLOCK) { |
| 53 | // MariaDB automatically rolls-back transactions in the event of a deadlock. |
| 54 | // However, we still initiate a manual rollback to ensure the connection gets released - see #13102. |
| 55 | try { |
| 56 | await options.transaction.rollback(); |
| 57 | } catch (error_) { |
| 58 | // Ignore errors - since MariaDB automatically rolled back, we're |
| 59 | // not that worried about this redundant rollback failing. |
| 60 | } |
| 61 | |
| 62 | options.transaction.finished = 'rollback'; |
| 63 | } |
| 64 | |
| 65 | error.sql = sql; |
| 66 | error.parameters = parameters; |
| 67 | throw this.formatError(error, errForStack.stack); |
| 68 | } finally { |
| 69 | complete(); |
| 70 | } |
| 71 | |
| 72 | if (showWarnings && results && results.warningStatus > 0) { |
| 73 | await this.logWarnings(results); |
| 74 | } |
| 75 | return this.formatResults(results); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * High level function that handles the results of a query execution. |
no test coverage detected