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

fix(compiler): correctly validate alias in order/group by clauses for joins #2537

Merged
merged 2 commits into from
Jul 28, 2023

Conversation

andrewmbenton
Copy link
Collaborator

Resolves #1886
Resolves #2398
Resolves #2399

@andrewmbenton
Copy link
Collaborator Author

andrewmbenton commented Jul 27, 2023

I think this resolves the referenced issues and pull request, but there is still a subtle bug (not new). The following query runs fine with psql but sqlc still gets confused even with the patch in this PR applied.

SELECT a.name AS name
FROM authors a JOIN authors b ON a.id = b.id
ORDER BY name;

Here's a playground link for v1.19.1: https://play.sqlc.dev/p/8648bbce740f0f059549e4e50e75bd073443080be5e5d12fd68aa5699f1b0c72

I think I'll create a new issue for this unless I can resolve it quickly.

@akutschera
Copy link
Contributor

FWIW, let's merge this one instead of #2399. Just my 2c

@kyleconroy kyleconroy merged commit 7d6377f into main Jul 28, 2023
@kyleconroy kyleconroy deleted the andrew/fix-order-by-with-alias branch July 28, 2023 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants