@zuzjs/orm 0.3.1 → 0.3.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/dist/drivers/mysql/index.js +10 -8
- package/package.json +1 -1
|
@@ -210,14 +210,16 @@ class MySqlDriver {
|
|
|
210
210
|
if (foreignKeys[tableName]) {
|
|
211
211
|
for (const fk of foreignKeys[tableName] || []) {
|
|
212
212
|
const relatedEntity = (0, index_js_1.toPascalCase)(fk.REFERENCED_TABLE_NAME);
|
|
213
|
-
entityCode.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
_imports.
|
|
219
|
-
|
|
220
|
-
_imports.
|
|
213
|
+
if (entityCode.includes(`fk${relatedEntity}!: ${relatedEntity};`) === false) {
|
|
214
|
+
entityCode.push(`\t@OneToOne(() => ${relatedEntity})`);
|
|
215
|
+
entityCode.push(`\t@JoinColumn({ name: "${fk.COLUMN_NAME}" })`);
|
|
216
|
+
entityCode.push(`\tfk${relatedEntity}!: ${relatedEntity};\n`);
|
|
217
|
+
imports.push(`import { ${relatedEntity} } from "./${fk.REFERENCED_TABLE_NAME}";`);
|
|
218
|
+
if (!_imports.includes(`OneToOne`))
|
|
219
|
+
_imports.push(`OneToOne`);
|
|
220
|
+
if (!_imports.includes(`JoinColumn`))
|
|
221
|
+
_imports.push(`JoinColumn`);
|
|
222
|
+
}
|
|
221
223
|
}
|
|
222
224
|
}
|
|
223
225
|
const Code = [
|