Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PostgreSQL: Support Interval expression #4144

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

Closed
hfhbd opened this issue May 8, 2023 · 1 comment · Fixed by #4152
Closed

PostgreSQL: Support Interval expression #4144

hfhbd opened this issue May 8, 2023 · 1 comment · Fixed by #4152

Comments

@hfhbd
Copy link
Collaborator

hfhbd commented May 8, 2023

SELECT INTERVAL '20m'

Should result into:

val result: org.postgresql.util.PGInterval = queries.selectInterval.executeAsOne()
@griffio
Copy link
Contributor

griffio commented May 9, 2023

What do you think, as the place to start, in regards to your mention of overriding the Literal Expression grammar?
Currently, 👨‍🎨 I now have something like this in the PostgreSql.bnf and some other overridden types as well.
Where the LiteralValueMixin is a new type PostgreSqlLiteralValue

literal_value ::= ( {numeric_literal}
                  | {string_literal}
                  | {blob_literal}
                  | NULL
                  | CURRENT_TIME
                  | CURRENT_DATE
                  | CURRENT_TIMESTAMP
                  | interval_expression ) {
  mixin = "app.cash.sqldelight.dialects.postgresql.grammar.mixins.LiteralValueMixin"
  override = true
}

Also, the following existing time literals are not supported either as the LiteralValueMixin only allows them on assignment. The below results in Cannot use time literal in expression

SELECT CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP

I may create a draft PR as I find out more - as this is quite a tricky one to sort out 🌵

I can also create an initial PR to add SqlTypes.INTERVAL to the sql-psi repo as is ANSI type (but not supported on Sqlite).

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.

2 participants