Skip to content

[BUG] JSQLParser Version : Postgres : BETWEEN with Cast #2288

Description

@davyboyhayes

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

  • Using a between expression, with cast doesn't parse correctly

SQL Example:

  • Simplified Query Example, focusing on the failing feature
SELECT * FROM tbl WHERE
day BETWEEN
  CAST(CAST((NOW() + INTERVAL '-30 day') AS date) AS timestamptz)
AND
  CAST(CAST((NOW() + INTERVAL '-1 day') AS date) AS timestamptz);
Image

Software Information:

  • JSqlParser 5.4-snapshot 2ff7342
  • PostgreSQL

Activity

  1. davyboyhayes commented on Aug 5, 2025

    @davyboyhayes
    ContributorAuthor
  2. manticore-projects commented on Aug 5, 2025

    @manticore-projects
    Contributor

    Greetings!

    I believe the LOOKAHEADS need to be changed into Semantic Lookaheads, e.g.:

    LOOKAHEAD(  ParenthesedSelect()  ) betweenExpressionStart = ParenthesedSelect()
    |
    LOOKAHEAD( RegularCondition() ) betweenExpressionStart = 
    |
    betweenExpressionStart  = SimpleExpression()
    
  3. manticore-projects commented on Aug 5, 2025

    @manticore-projects
    Contributor

    I will fix that tomorrow since I have another case I have to work on.

  4. davyboyhayes commented on Aug 5, 2025

    @davyboyhayes
    ContributorAuthor

    I've raised #2289. Feel free to ignore it if you have more to build on, but your suggestion results in a passing test for that SQL, thanks!

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

Metadata

Metadata

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions