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
[@loopback/sequelize] Duplicate column names in relation queries #9617
Comments
I personally feel that when it comes to anything that gets included in query be it table name, column name, relations keys etc. We should explicitly set it rather than relying on LoopBack's defaults for the obvious surety reasons. Although it would be very beneficial for new adopters to face as little code changes as possible for them to implement this in their project. I already have so much in my bucket list so I'll pick this up in the first week of July, unless any one else from the community wants to work on this. |
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
@KalleV I see some commits from you on your forked repo. Were you able to fix this issue ? If yes, would you mind to submit a PR in this repo too, so that community can benefit from it too ? |
Describe the bug
Repository queries with relations that do not explicitly set all the keyTo / keyFrom / through properties will lead to broken SQL queries that contain duplicated title case column names mixed in with the expected camelcase columns.
Example:
Relates to:
sequelize/sequelize#9328
#9591
sourcefuse/loopback4-sequelize#35
Logs
No response
Additional information
Workaround seems to be to go through all the Entity relations and explicitly set all the relation key names but that can be time-consuming and error-prone with a larger project. It seems like it might be possible to mitigate this at the loopback model to Sequelize relation layer.
Reproduction
With these changes, running the tests for the Sequelize extension will replicate the error:
KalleV@3c29d85
Turns out it's necessary to define additional "belongsTo" relations in other entities before this happens. The extra relation is added to the "Patient" entity in this case. With this set up, I am seeing the following happen:
The text was updated successfully, but these errors were encountered: