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

code request "is [not] distinct from" #1879

Open
tballard opened this issue Feb 3, 2023 · 4 comments
Open

code request "is [not] distinct from" #1879

tballard opened this issue Feb 3, 2023 · 4 comments
Labels

Comments

@tballard
Copy link

tballard commented Feb 3, 2023

The "is not distinct from" feature (basically "=" that handles nulls, too) would be as easy to implement as "eq" or "gt" or something and much appreciated. I don't think I missed it ...

@seratch seratch added the core label Feb 5, 2023
@seratch
Copy link
Member

seratch commented Feb 5, 2023

Hi @tballard, thanks for sharing this but I still don't get the point. Would you mind sharing a bit more detail with code examples or related documents on the syntax?

@tballard
Copy link
Author

tballard commented Feb 5, 2023

Anywhere you can write the condition "t1.col1 = t2.col2" you can write "t1.col1 is not distinct from t2.col2", which is the same except for being true if both are null. You can also take out the "not" as you might expect. The syntax is awkward, no doubt because they were trying not to add any new keywords. I just thought it would be easy to add to your DSL, and hey, you could probably improve on the name. https://www.postgresql.org/docs/current/functions-comparison.html

If you are looking for useful features to add, two more I use often that I didn't see any mention of are the "distinct on" feature that allows dividing into ranges and pulling a particular value from the range and the "with" construct that allows defining queries and then using them like tables in the succeeding queries. And "exists" as in "select exists (select something from wherever where whatever)" ...

@seratch
Copy link
Member

seratch commented Feb 6, 2023

Hi @tballard, thanks for your detailed reply! Since "is not distinct from" is not a commonly implemented syntax in other RDBMSs (perhaps, PostgreSQL only?), so I hesitate to add it to this library's Query SDL at this moment.

You can go with .append(sqls"${a.col1} is not distinct from ${b.col2}") instead.

Although I am not planning to add DSLs for it in the short term, let me keep this issue open for future discussions.

@tballard
Copy link
Author

tballard commented Feb 6, 2023

Thanks for directing my attention to ".append". It should be helpful with some postgresql quirks.

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

No branches or pull requests

2 participants