Skip to content

Commit f8f14f2

Browse files
leibowitzdziraf
andauthored
fix: return tableName in property.reference() (#51)(@leibowitz)
* fix: return tableName in property.reference() Fix issue when foreign key is not defining a reference, but a relationship exists, resulting in this: Error: There are no resources with given id: "[object Object]" Or Error: There are no resources with given id: ""schema"."table"" * chore: temporarily cast references.model as any Co-authored-by: Rafał Dzięgielewski <rafal.dzieg@gmail.com>
1 parent 4dd8523 commit f8f14f2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/property.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class Property extends BaseProperty {
7373
if (this.sequelizePath.references === 'string') {
7474
return this.sequelizePath.references as string;
7575
} if (this.sequelizePath.references && typeof this.sequelizePath.references !== 'string') {
76+
if (this.sequelizePath.references.model && typeof this.sequelizePath.references.model !== 'string') {
77+
return (this.sequelizePath.references?.model as any)?.tableName as string
78+
}
7679
return this.sequelizePath.references?.model as string;
7780
}
7881
return null;

0 commit comments

Comments
 (0)