@rws-framework/db 3.7.3 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -142,14 +142,16 @@ class RWSModel {
|
|
|
142
142
|
const timeSeriesHydrationFields = [];
|
|
143
143
|
for (const key in this) {
|
|
144
144
|
if (await this.hasRelation(key)) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
if (this[key] === null) {
|
|
146
|
+
// For null relations, use disconnect or set to null
|
|
147
|
+
data[key] = {
|
|
148
|
+
disconnect: true
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
data[key] = this.bindRelation(key, this[key]);
|
|
152
153
|
}
|
|
154
|
+
// Don't try to set the foreign key directly anymore
|
|
153
155
|
continue;
|
|
154
156
|
}
|
|
155
157
|
if (!(await this.isDbVariable(key))) {
|
package/package.json
CHANGED
|
@@ -182,15 +182,16 @@ class RWSModel<T> implements IModel {
|
|
|
182
182
|
|
|
183
183
|
for (const key in (this as any)) {
|
|
184
184
|
if (await this.hasRelation(key)) {
|
|
185
|
-
|
|
185
|
+
if (this[key] === null) {
|
|
186
|
+
// For null relations, use disconnect or set to null
|
|
187
|
+
data[key] = {
|
|
188
|
+
disconnect: true
|
|
189
|
+
};
|
|
190
|
+
} else {
|
|
191
|
+
data[key] = this.bindRelation(key, this[key]);
|
|
192
|
+
}
|
|
186
193
|
|
|
187
|
-
|
|
188
|
-
const relationKey = await this.getRelationKey(key);
|
|
189
|
-
if(relationKey){
|
|
190
|
-
data[relationKey] = null;
|
|
191
|
-
delete data[key];
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
+
// Don't try to set the foreign key directly anymore
|
|
194
195
|
continue;
|
|
195
196
|
}
|
|
196
197
|
|