@stonyx/orm 0.3.2-beta.80 → 0.3.2-beta.81
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/serializer.js +11 -0
- package/package.json +1 -1
- package/src/serializer.ts +12 -0
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
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;
|