Skip to content
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

union does not add parentheses to the individual selects #495

Closed
adrian-budau opened this issue Nov 2, 2022 · 2 comments · Fixed by #498
Closed

union does not add parentheses to the individual selects #495

adrian-budau opened this issue Nov 2, 2022 · 2 comments · Fixed by #498
Assignees
Milestone

Comments

@adrian-budau
Copy link
Contributor

Description

Steps to Reproduce

  1. Create two selectstatements on the same table (cake)
  2. First one should be a simple select statement
  3. Second should have both a join (cake_filling) and an order by on a column from the joined table
  4. Union them

Expected Behavior

SELECT cake.column FROM cake (UNION SELECT cake.column FROM cake INNER JOIN cake_filling ON cake.id = cake_filling.cake_id ORDER BY cake_filling.filling_id)

Actual Behavior

SELECT cake.column FROM cake UNION SELECT cake.column FROM cake INNER JOIN cake_filling ON cake.id = cake_filling.cake_id ORDER BY cake_filling.filling_id which will error:

Error 1250(42000): Table cake_filling from one of the SELECTs cannot be used in field list.

Reproduces How Often

Always on Mysql (That I Tested), but I think it's a problem on all database flavours.

Versions

0.27.1

Additional Information

I triggered it in personal code so I don't have an example, could make one if needed.

@ikrivosheev ikrivosheev added this to the 0.28.x milestone Nov 2, 2022
@adrian-budau
Copy link
Contributor Author

Would you mind if I tried to tackle this and do a PR?

@ikrivosheev
Copy link
Member

Would you mind if I tried to tackle this and do a PR?

@adrian-budau hello, yes! We are welcome for a contribution)

adrian-budau added a commit to adrian-budau/sea-query that referenced this issue Nov 2, 2022
@billy1624 billy1624 moved this to Triage in SeaQL Dev Tracker Nov 4, 2022
ikrivosheev added a commit that referenced this issue Nov 6, 2022
Wrap unions into parenthesis (#495)
@billy1624 billy1624 moved this from Triage to Done in SeaQL Dev Tracker Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants