[ 
https://issues.apache.org/jira/browse/CAY-2972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrus Adamchik closed CAY-2972.
--------------------------------
    Resolution: Fixed

> Fewer parentheses in generated SQL
> ----------------------------------
>
>                 Key: CAY-2972
>                 URL: https://issues.apache.org/jira/browse/CAY-2972
>             Project: Cayenne
>          Issue Type: Task
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>            Priority: Minor
>             Fix For: 5.0-M3
>
>
> Cayenne's fluent SQL generator (used by ObjectSelect, DELETE, UPDATE, CASE, 
> join ON clauses, etc.) wraps every expression node in parentheses unless its 
> parent is a top-level clause. There is no operator-precedence awareness. This 
> produces noisy SQL like:
> {noformat}
>  DELETE FROM test WHERE ((col1 = 1) AND (col2 = 'test')) AND (col3 IS 
> NULL){noformat}
>  So, let's do this: 
>  1. Drop parens around all comparison operators (=, <>, <, <=, >, >=, LIKE, 
> BETWEEN) when they sit directly under AND/OR.
>  2. Drop parens for chained same-operator logical connectives (AND under AND, 
> OR under OR).
>  3. Keep parens for mixed AND/OR combinations (e.g. (a OR b) AND c) and for 
> everything else (arithmetic, bitwise, custom ops, NOT)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to