@stonyx/orm 0.3.2-beta.80 → 0.3.2-beta.82
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/dist/dynamodb/dynamodb-db.js +2 -2
- package/dist/serializer.js +11 -0
- package/package.json +1 -1
- package/src/dynamodb/dynamodb-db.ts +2 -2
- package/src/serializer.ts +12 -0
|
@@ -368,7 +368,7 @@ export default class DynamoDBDB {
|
|
|
368
368
|
if (currentData[col] !== oldState[col]) {
|
|
369
369
|
const value = currentData[col] ?? null;
|
|
370
370
|
// Date objects must be serialized to ISO-8601 strings for DynamoDB 'S' storage
|
|
371
|
-
changedData[col] = (
|
|
371
|
+
changedData[col] = (value instanceof Date)
|
|
372
372
|
? value.toISOString()
|
|
373
373
|
: value;
|
|
374
374
|
}
|
|
@@ -540,7 +540,7 @@ export default class DynamoDBDB {
|
|
|
540
540
|
if (data[col] !== undefined) {
|
|
541
541
|
const value = data[col];
|
|
542
542
|
// Date objects must be serialized to ISO-8601 strings for DynamoDB 'S' storage
|
|
543
|
-
item[col] = (
|
|
543
|
+
item[col] = (value instanceof Date)
|
|
544
544
|
? value.toISOString()
|
|
545
545
|
: value;
|
|
546
546
|
}
|
package/dist/serializer.js
CHANGED
|
@@ -105,6 +105,17 @@ export default class Serializer {
|
|
|
105
105
|
else {
|
|
106
106
|
rec[key] = childRecord;
|
|
107
107
|
relatedRecords[key] = childRecord;
|
|
108
|
+
// Preserve the raw FK value in __data when the belongsTo handler
|
|
109
|
+
// couldn't resolve the target (e.g., memory:false model not loaded).
|
|
110
|
+
// This allows adapters to read the FK from __data as a fallback
|
|
111
|
+
// when __relationships[key] is null. Only store when `data` is a
|
|
112
|
+
// truthy non-object — i.e., a raw FK string/number that the handler
|
|
113
|
+
// attempted but failed to resolve. When `data` is null/undefined
|
|
114
|
+
// (optional empty relationship) we intentionally skip to preserve
|
|
115
|
+
// the existing behavior of not populating __data for empty FKs.
|
|
116
|
+
if (childRecord === null && data && typeof data !== 'object') {
|
|
117
|
+
parsedData[key] = data;
|
|
118
|
+
}
|
|
108
119
|
}
|
|
109
120
|
continue;
|
|
110
121
|
}
|
package/package.json
CHANGED
|
@@ -525,7 +525,7 @@ export default class DynamoDBDB {
|
|
|
525
525
|
if (currentData[col] !== oldState[col]) {
|
|
526
526
|
const value = currentData[col] ?? null;
|
|
527
527
|
// Date objects must be serialized to ISO-8601 strings for DynamoDB 'S' storage
|
|
528
|
-
changedData[col] = (
|
|
528
|
+
changedData[col] = (value instanceof Date)
|
|
529
529
|
? value.toISOString()
|
|
530
530
|
: value;
|
|
531
531
|
}
|
|
@@ -746,7 +746,7 @@ export default class DynamoDBDB {
|
|
|
746
746
|
if (data[col] !== undefined) {
|
|
747
747
|
const value = data[col];
|
|
748
748
|
// Date objects must be serialized to ISO-8601 strings for DynamoDB 'S' storage
|
|
749
|
-
item[col] = (
|
|
749
|
+
item[col] = (value instanceof Date)
|
|
750
750
|
? value.toISOString()
|
|
751
751
|
: value;
|
|
752
752
|
}
|
package/src/serializer.ts
CHANGED
|
@@ -120,6 +120,18 @@ export default class Serializer {
|
|
|
120
120
|
} else {
|
|
121
121
|
rec[key] = childRecord;
|
|
122
122
|
relatedRecords[key] = childRecord;
|
|
123
|
+
|
|
124
|
+
// Preserve the raw FK value in __data when the belongsTo handler
|
|
125
|
+
// couldn't resolve the target (e.g., memory:false model not loaded).
|
|
126
|
+
// This allows adapters to read the FK from __data as a fallback
|
|
127
|
+
// when __relationships[key] is null. Only store when `data` is a
|
|
128
|
+
// truthy non-object — i.e., a raw FK string/number that the handler
|
|
129
|
+
// attempted but failed to resolve. When `data` is null/undefined
|
|
130
|
+
// (optional empty relationship) we intentionally skip to preserve
|
|
131
|
+
// the existing behavior of not populating __data for empty FKs.
|
|
132
|
+
if (childRecord === null && data && typeof data !== 'object') {
|
|
133
|
+
parsedData[key] = data;
|
|
134
|
+
}
|
|
123
135
|
}
|
|
124
136
|
|
|
125
137
|
continue;
|