groovy

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

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-6, 1.0-RC-1
  • Fix Version/s: 1.1-beta-2
  • Component/s: ast builder
  • Labels:
    None
  • Environment:
    Windows, HSQLDB
  • Testcase included:
    yes
  • Number of attachments :
    0

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)

Activity

Hide
Paul King added a comment -

Jon, you still have the attachment? It doesn't seem to be here at the moment.

Show
Paul King added a comment - Jon, you still have the attachment? It doesn't seem to be here at the moment.
Hide
Jon Skeet added a comment -

Unfortunately not - I've changed job and reinstalled my laptop since then

Jon

Show
Jon Skeet added a comment - Unfortunately not - I've changed job and reinstalled my laptop since then Jon
Hide
Paul King added a comment -

Should be fixed in HEAD

Show
Paul King added a comment - Should be fixed in HEAD
Hide
Paul King added a comment -

No further feedback, assuming fixed

Show
Paul King added a comment - No further feedback, assuming fixed

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: