Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6436

JDBC adapter generates SQL missing parentheses when comparing 3 values with the same precedence like (a=b)=c

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.37.0
    • 1.38.0
    • core

    Description

      Running the following unit test in JdbcAdapterTest fails with

      @Test void testOperatorInWhere() {
          CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
              .query("select * from \"sales_fact_1997\" "
                  + "where (\"product_id\" = 1) = ?")
              .consumesPreparedStatement(p -> p.setBoolean(1, true))
              .runs();
        }
      
      Caused by: java.sql.SQLSyntaxErrorException: unexpected token: = : line: 3 in statement [SELECT *
      FROM "foodmart"."sales_fact_1997"
      WHERE "product_id" = 1 = ?
      

      Attachments

        Issue Links

          Activity

            People

              nobigo xiong duan
              kramerul Ulrich Kramer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: