MCPcopy
hub / github.com/sequelize/sequelize / _injectAttributes

Method _injectAttributes

lib/associations/has-one.js:80–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78
79 // the id is in the target table
80 _injectAttributes() {
81 const newAttributes = {
82 [this.foreignKey]: {
83 type: this.options.keyType || this.source.rawAttributes[this.sourceKey].type,
84 allowNull: true,
85 ...this.foreignKeyAttribute
86 }
87 };
88
89 if (this.options.constraints !== false) {
90 const target = this.target.rawAttributes[this.foreignKey] || newAttributes[this.foreignKey];
91 this.options.onDelete = this.options.onDelete || (target.allowNull ? 'SET NULL' : 'CASCADE');
92 this.options.onUpdate = this.options.onUpdate || 'CASCADE';
93 }
94
95 Helpers.addForeignKeyConstraints(newAttributes[this.foreignKey], this.source, this.target, this.options, this.sourceKeyField);
96 Utils.mergeDefaults(this.target.rawAttributes, newAttributes);
97
98 this.target.refreshAttributes();
99
100 this.identifierField = this.target.rawAttributes[this.foreignKey].field || this.foreignKey;
101
102 Helpers.checkNamingCollision(this);
103
104 return this;
105 }
106
107 mixin(obj) {
108 const methods = ['get', 'set', 'create'];

Callers 1

singleLinkedFunction · 0.45

Calls 1

refreshAttributesMethod · 0.80

Tested by

no test coverage detected