Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1550

Groovy Sql (or AST builder) doesn't respect bracketing of logical operators

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-6, 1.0-RC-1
    • 1.1-beta-2
    • ast builder
    • None
    • Windows, HSQLDB

    Description

      Version used: both JSR-6 and the snapshot downloaded today in the Grails 0.3 snapshot.

      (AST builder selected as a component on the grounds that I'm not sure whether it's in Groovy SQL or AST.)

      Groovy SQL should take note of the brackets in expressions which are presumably in the AST somewhere.

      For instance, DataSet.findAll

      { it.x=='zzz' && (it.y==20 || it.x=='xxx') }

      should generate SQL of:

      select * from Test where x = ? and (y = ? or x = ?)

      but there are no brackets in the generated SQL. This means that in the attached test case, a row is found, despite the fact that it shouldn't be. (x can't be both zzz and xxx).

      (Attachment isn't a JUnit test case - it's a Groovy script with a failing assertion)

      Attachments

        Activity

          People

            paulk Paul King
            jskeet Jon Skeet
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: