@rapidd/build 1.1.1 → 1.1.2
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/package.json
CHANGED
|
@@ -104,6 +104,21 @@ function findForeignKeyField(relation, currentModel, relatedModel) {
|
|
|
104
104
|
return relation.relationFromFields[0];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// For optional one-to-one relations where FK is on the other side
|
|
108
|
+
// (e.g., users -> student_profiles? where userId is in student_profiles)
|
|
109
|
+
if (!relation.isArray) {
|
|
110
|
+
// Find the corresponding relation in the related model that points back
|
|
111
|
+
for (const relField of Object.values(relatedModel.fields)) {
|
|
112
|
+
if (relField.kind === 'object' &&
|
|
113
|
+
relField.relationName === relation.relationName &&
|
|
114
|
+
relField.relationFromFields &&
|
|
115
|
+
relField.relationFromFields.length > 0) {
|
|
116
|
+
// This is the FK field in the related model (pointing back to us)
|
|
117
|
+
return relField.relationFromFields[0];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
// If no fields on this side, the FK must be on the other side (shouldn't use this relation for filtering)
|
|
108
123
|
return null;
|
|
109
124
|
}
|