@sdflc/backend-helpers 1.0.138 → 1.0.139
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.
- package/build/BaseGateway.js +18 -2
- package/build/esm/BaseGateway.js +18 -2
- package/package.json +1 -1
package/build/BaseGateway.js
CHANGED
|
@@ -1230,10 +1230,26 @@ class BaseGateway {
|
|
|
1230
1230
|
if (!args || objects.length === 0) {
|
|
1231
1231
|
return [];
|
|
1232
1232
|
}
|
|
1233
|
+
// The framework's OWN id is applied AFTER transformOnCreate, never through it.
|
|
1234
|
+
// transformOnCreate strips `id` — deliberately, so a CALLER-supplied id is never
|
|
1235
|
+
// honoured — and it cannot tell the caller's id from ours once both are merged into
|
|
1236
|
+
// one payload. Passing the generated id in that payload (as this did until now) meant
|
|
1237
|
+
// the strip deleted the id we had just made: `generateId()` became inert, every insert
|
|
1238
|
+
// silently fell back to the column's own default, and every create logged
|
|
1239
|
+
// `field "id" is not writable on create and was stripped from the payload`.
|
|
1240
|
+
// A caller id is still dropped — it is stripped before we get here.
|
|
1241
|
+
// Mirrors what `set()` below already does, and restores the pre-1.0.135 insert payload
|
|
1242
|
+
// (the strip landed in 1.0.135 and started swallowing this id).
|
|
1243
|
+
const idField = String(this.getIdField()).split('.').pop();
|
|
1233
1244
|
for (let idx = 0, len = objects.length; idx < len; ++idx) {
|
|
1234
1245
|
const object = objects[idx];
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1246
|
+
const transformed = await this.transformOnCreate({ ...object });
|
|
1247
|
+
// Only when nothing else has set it — `hasLang` + `localizationForField` builds a
|
|
1248
|
+
// COMPOSITE id in transformOnCreate, and that one must stand.
|
|
1249
|
+
if (transformed[idField] == null) {
|
|
1250
|
+
transformed[idField] = await this.generateId(object);
|
|
1251
|
+
}
|
|
1252
|
+
objects[idx] = transformed;
|
|
1237
1253
|
}
|
|
1238
1254
|
const result = [];
|
|
1239
1255
|
const chunks = (0, utils_1.arrToChunks)(objects, this.config?.insertChunkSize || DEFAULT_CHUNCK_SIZE);
|
package/build/esm/BaseGateway.js
CHANGED
|
@@ -1224,10 +1224,26 @@ class BaseGateway {
|
|
|
1224
1224
|
if (!args || objects.length === 0) {
|
|
1225
1225
|
return [];
|
|
1226
1226
|
}
|
|
1227
|
+
// The framework's OWN id is applied AFTER transformOnCreate, never through it.
|
|
1228
|
+
// transformOnCreate strips `id` — deliberately, so a CALLER-supplied id is never
|
|
1229
|
+
// honoured — and it cannot tell the caller's id from ours once both are merged into
|
|
1230
|
+
// one payload. Passing the generated id in that payload (as this did until now) meant
|
|
1231
|
+
// the strip deleted the id we had just made: `generateId()` became inert, every insert
|
|
1232
|
+
// silently fell back to the column's own default, and every create logged
|
|
1233
|
+
// `field "id" is not writable on create and was stripped from the payload`.
|
|
1234
|
+
// A caller id is still dropped — it is stripped before we get here.
|
|
1235
|
+
// Mirrors what `set()` below already does, and restores the pre-1.0.135 insert payload
|
|
1236
|
+
// (the strip landed in 1.0.135 and started swallowing this id).
|
|
1237
|
+
const idField = String(this.getIdField()).split('.').pop();
|
|
1227
1238
|
for (let idx = 0, len = objects.length; idx < len; ++idx) {
|
|
1228
1239
|
const object = objects[idx];
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1240
|
+
const transformed = await this.transformOnCreate({ ...object });
|
|
1241
|
+
// Only when nothing else has set it — `hasLang` + `localizationForField` builds a
|
|
1242
|
+
// COMPOSITE id in transformOnCreate, and that one must stand.
|
|
1243
|
+
if (transformed[idField] == null) {
|
|
1244
|
+
transformed[idField] = await this.generateId(object);
|
|
1245
|
+
}
|
|
1246
|
+
objects[idx] = transformed;
|
|
1231
1247
|
}
|
|
1232
1248
|
const result = [];
|
|
1233
1249
|
const chunks = arrToChunks(objects, this.config?.insertChunkSize || DEFAULT_CHUNCK_SIZE);
|