(results, metaData)
| 374 | } |
| 375 | |
| 376 | handleInsertQuery(results, metaData) { |
| 377 | if (this.instance) { |
| 378 | // add the inserted row id to the instance |
| 379 | const autoIncrementAttribute = this.model.autoIncrementAttribute; |
| 380 | let id = null; |
| 381 | let autoIncrementAttributeAlias = null; |
| 382 | |
| 383 | if (Object.prototype.hasOwnProperty.call(this.model.rawAttributes, autoIncrementAttribute) && |
| 384 | this.model.rawAttributes[autoIncrementAttribute].field !== undefined) |
| 385 | autoIncrementAttributeAlias = this.model.rawAttributes[autoIncrementAttribute].field; |
| 386 | |
| 387 | id = id || results && results[0][this.getInsertIdField()]; |
| 388 | id = id || metaData && metaData[this.getInsertIdField()]; |
| 389 | id = id || results && results[0][autoIncrementAttribute]; |
| 390 | id = id || autoIncrementAttributeAlias && results && results[0][autoIncrementAttributeAlias]; |
| 391 | |
| 392 | this.instance[autoIncrementAttribute] = id; |
| 393 | |
| 394 | if (this.instance.dataValues) { |
| 395 | for (const key in results[0]) { |
| 396 | if (Object.prototype.hasOwnProperty.call(results[0], key)) { |
| 397 | const record = results[0][key]; |
| 398 | |
| 399 | const attr = _.find(this.model.rawAttributes, attribute => attribute.fieldName === key || attribute.field === key); |
| 400 | |
| 401 | this.instance.dataValues[attr && attr.fieldName || key] = record; |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | module.exports = Query; |
no test coverage detected