-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@belongsTo with a default “keyTo” leads to a broken relation query #35
Comments
I did some more investigation on this one and found this in the documentation for the default foreign key set by Sequelize:
|
Hii @KalleV |
Ok looks like it wasn't quite that simple to replicate in isolation. To replicate it with minimal code, I had to introduce another belongsTo relation in another entity in addition to leaving out the relation keys in the decorator: KalleV/loopback-next@3c29d85 I filled in more details in the loopbackio/loopback-next#9617 issue's reproduction section. |
Resolves: loopbackio#9591 Signed-off-by: KalleV <kvirtaneva@gmail.com> test(sequelize): replicate duplicate column error with Sequelize belongsTo Relates to: - loopbackio#9617 - sourcefuse/loopback4-sequelize#35
Describe the bug
The belongsTo relation mapping from Loopback 4 to Sequelize has an edge case when using the default “keyTo” option.
References:
https://loopback.io/doc/en/lb4/BelongsTo-relation.html#relation-metadata
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Successful query when using the default options generated by Loopback for a belongsTo relation.
Additional context
I haven’t confirmed it but I assume the code in this section might need an update:
loopback4-sequelize/src/sequelize/sequelize.repository.base.ts
Line 658 in a6aaaf0
Quick workaround is to explicitly set the “{ keyTo }” in the decorator options.
The text was updated successfully, but these errors were encountered: