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

Support for PostgreSQL DISTINCT ON syntax #4580

Closed
lnhrdt opened this issue Aug 30, 2023 · 2 comments · Fixed by #4584
Closed

Support for PostgreSQL DISTINCT ON syntax #4580

lnhrdt opened this issue Aug 30, 2023 · 2 comments · Fixed by #4584

Comments

@lnhrdt
Copy link
Contributor

lnhrdt commented Aug 30, 2023

SQLDelight Version

2.0.0

SQLDelight Dialect

PostgreSQL

Describe the Bug

The PostgreSQL DISTINCT ON syntax does not seem to be supported. Queries like this do not compile in SQLDelight:

test:
SELECT DISTINCT ON (name) *
FROM person
ORDER BY person.created_at DESC;

Compilation errors appear on the name of the query:

'{' expected, got ':'

https://www.postgresql.org/docs/current/sql-select.html#SQL-DISTINCT

Stacktrace

No response

@lnhrdt lnhrdt added the bug label Aug 30, 2023
@griffio
Copy link
Contributor

griffio commented Aug 31, 2023

😎 I will have a look and do a PR to see what happens

It was on the list 📜 #3944 (reply in thread)

This syntax should also validate "SELECT DISTINCT ON expressions must match initial ORDER BY expressions", as though that test example was provided for context, if implemented it shouldn't compile 🙅 , the test query should be

SELECT DISTINCT ON (name) *
FROM person
ORDER BY person.name, person.created_at DESC;

I also recently created another discussion about the current schema migration support (if you have any requirements 🛎️ ) - #4572

@lnhrdt
Copy link
Contributor Author

lnhrdt commented Aug 31, 2023

Aha the list in #3944 (reply in thread)! I'd forgotten about that, thank you. Over the last 2 months I've definitely run into a few of those "not supported syntax" items so I just shared some more thoughts in there.

Fascinating what you're discussing in #4572. I feel out of my depth discussing how to better support vendor extensions in sql-psi but I applaud and appreciate your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants