-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix DB-specific, query-related exceptions #3156
Conversation
36b3e97
to
cf69397
Compare
cf69397
to
a45d47f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments/questions. Thanks for working on this!
a45d47f
to
49a3dbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thank you @aitbw for this much needed fix!
I've left a minor comment, hope it makes sense
PostgreSQL is very picky when building a SQL query that requires SELECT and ORDER BY methods; the attribute you want to use to sort the results must be explicitly selected; otherwise, PG raises an exception
The SQL queries specified on said helper on lines 10 and 15 were redundantly selecting the `id` attribute for `spree_products` table, which caused MySQL to raise an exception about a duplicate column name since said attribute is already being selected through the `spree_products.*` statement
49a3dbe
to
3db4c93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aitbw !
@solidusio/core-team can we have another review here, please? This issue is making all other PRs fail. |
Description
I was being greeted with the following errors when running specs specifying PostgreSQL or MySQL as database engine:
PG::InvalidColumnReference
This was happening because PG is extremely picky when using the
SELECT
andORDER BY
methods; it requires that the developer must explicitly select the attribute(s) that are going to be used to sort the query results.Mysql2::Error: Duplicate column name
This exception was being raised because the affected code was selecting the
id
attribute forSpree::Product
twice. (It was being already selected by thespree_products.*
statement)See the following failed builds as reference for the errors:
The issue is present from Rails v5.2.3 onwards, seems like rails/rails#35361 introduced this regression. (shoutout to @kennyadsl and @spaghetticode for pointing this out to me)
Checklist: