MCPcopy
hub / github.com/sequelize/sequelize / attributesToSQL

Method attributesToSQL

src/dialects/db2/query-generator.js:675–703  ·  view source on GitHub ↗
(attributes, options)

Source from the content-addressed store, hash-verified

673 }
674
675 attributesToSQL(attributes, options) {
676 const result = {},
677 existingConstraints = [];
678 let key,
679 attribute;
680
681 for (key in attributes) {
682 attribute = attributes[key];
683
684 if (attribute.references) {
685
686 if (existingConstraints.indexOf(attribute.references.model.toString()) !== -1) {
687 // no cascading constraints to a table more than once
688 attribute.onDelete = '';
689 attribute.onUpdate = '';
690 } else if (attribute.unique && attribute.unique === true) {
691 attribute.onDelete = '';
692 attribute.onUpdate = '';
693 } else {
694 existingConstraints.push(attribute.references.model.toString());
695 }
696 }
697
698 if (key && !attribute.field && typeof attribute === 'object') attribute.field = key;
699 result[attribute.field || key] = this.attributeToSQL(attribute, options);
700 }
701
702 return result;
703 }
704
705 createTrigger() {
706 throwMethodUndefined('createTrigger');

Callers 8

createTableMethod · 0.45
changeColumnMethod · 0.45
renameColumnMethod · 0.45
createTableMethod · 0.45

Calls 2

attributeToSQLMethod · 0.95
toStringMethod · 0.65

Tested by

no test coverage detected