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

Method handleInsertQuery

src/dialects/oracle/query.js:649–674  ·  view source on GitHub ↗
(results, metaData)

Source from the content-addressed store, hash-verified

647 }
648
649 handleInsertQuery(results, metaData) {
650 if (this.instance && results.length > 0) {
651 if ('pkReturnVal' in results[0]) {
652 // The PK of the table is a reserved word (ex : uuid), we have to change the name in the result for the model to find the value correctly
653 results[0][this.model.primaryKeyAttribute] = results[0].pkReturnVal;
654 delete results[0].pkReturnVal;
655 }
656 // add the inserted row id to the instance
657 const autoIncrementField = this.model.autoIncrementAttribute;
658 let autoIncrementFieldAlias = null,
659 id = null;
660
661 if (
662 Object.prototype.hasOwnProperty.call(this.model.rawAttributes, autoIncrementField) &&
663 this.model.rawAttributes[autoIncrementField].field !== undefined
664 )
665 autoIncrementFieldAlias = this.model.rawAttributes[autoIncrementField].field;
666
667 id = id || results && results[0][this.getInsertIdField()];
668 id = id || metaData && metaData[this.getInsertIdField()];
669 id = id || results && results[0][autoIncrementField];
670 id = id || autoIncrementFieldAlias && results && results[0][autoIncrementFieldAlias];
671
672 this.instance[autoIncrementField] = id;
673 }
674 }
675}

Callers 1

formatResultsMethod · 0.95

Calls 1

getInsertIdFieldMethod · 0.95

Tested by

no test coverage detected