@famgia/omnify-core 0.0.128 → 0.0.129
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/index.cjs +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2481,6 +2481,9 @@ function validateDefaultValue(typeName, value, property) {
|
|
|
2481
2481
|
|
|
2482
2482
|
// src/validation/validator.ts
|
|
2483
2483
|
var VALID_ID_TYPES = ["Int", "BigInt", "Uuid", "String"];
|
|
2484
|
+
function toSnakeCase(str) {
|
|
2485
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
2486
|
+
}
|
|
2484
2487
|
function buildLocation7(file, line, column) {
|
|
2485
2488
|
const loc = { file };
|
|
2486
2489
|
if (line !== void 0) {
|
|
@@ -2916,6 +2919,20 @@ function validateAssociations(schema, allSchemas) {
|
|
|
2916
2919
|
)
|
|
2917
2920
|
);
|
|
2918
2921
|
}
|
|
2922
|
+
if (relation === "ManyToOne" || relation === "OneToOne" && !assocProp.mappedBy) {
|
|
2923
|
+
const expectedFkColumn = `${toSnakeCase(name)}_id`;
|
|
2924
|
+
if (schema.properties[expectedFkColumn]) {
|
|
2925
|
+
errors.push(
|
|
2926
|
+
validationError(
|
|
2927
|
+
`Duplicate FK definition: Property '${expectedFkColumn}' conflicts with Association '${name}'`,
|
|
2928
|
+
buildLocation7(schema.filePath),
|
|
2929
|
+
`Both create the same column '${expectedFkColumn}'. Choose one approach:
|
|
2930
|
+
1. Use Association only (remove '${expectedFkColumn}' property) - recommended
|
|
2931
|
+
2. Use explicit FK only (remove '${name}' Association)`
|
|
2932
|
+
)
|
|
2933
|
+
);
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2919
2936
|
}
|
|
2920
2937
|
return errors;
|
|
2921
2938
|
}
|