You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andreas Hartmann (JIRA)" <ji...@apache.org> on 2010/01/21 15:02:54 UTC
[jira] Created: (CAY-1371) EJBQL query doesn't preserve grouping by
brackets
EJBQL query doesn't preserve grouping by brackets
-------------------------------------------------
Key: CAY-1371
URL: https://issues.apache.org/jira/browse/CAY-1371
Project: Cayenne
Issue Type: Bug
Components: Core Library
Affects Versions: 3.0RC2
Reporter: Andreas Hartmann
EJBQL statement:
SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
Resulting query:
SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
In the resulting query, the brackets surrounding the OR conjunction are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAY-1371) EJBQL query doesn't preserve grouping
by brackets
Posted by "Andreas Hartmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803299#action_12803299 ]
Andreas Hartmann commented on CAY-1371:
---------------------------------------
The error seems to occur when the SQL string is built. The hierarchy of the EJBQL expression looks good:
<pre>
Select
SelectClause
SelectExpressions
SelectExpression
Aggregate
Count
Identifier [t]
From
FromItem
AbstractSchemaName
IdentificationVariable [User]
Identifier [t]
Where
And
Equals
Path
Identifier [t]
IdentificationVariable [language]
IdentificationVariable [code]
StringLiteral ['fr']
Or
Like
Upper
Path
Identifier [t]
IdentificationVariable [email]
PatternValue
StringLiteral ['%ANDREAS.HARTMANN@GMAIL.COM%']
Like
Upper
Path
Identifier [t]
IdentificationVariable [email]
PatternValue
StringLiteral ['%NOBBY@MACBAY.DE%']
</pre>
> EJBQL query doesn't preserve grouping by brackets
> -------------------------------------------------
>
> Key: CAY-1371
> URL: https://issues.apache.org/jira/browse/CAY-1371
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0RC2
> Reporter: Andreas Hartmann
>
> EJBQL statement:
> SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
> Resulting query:
> SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
> In the resulting query, the brackets surrounding the OR clause are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping by
brackets
Posted by "Andreas Hartmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Hartmann updated CAY-1371:
----------------------------------
Description:
EJBQL statement:
SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
Resulting query:
SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
In the resulting query, the brackets surrounding the OR clause are lost.
was:
EJBQL statement:
SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
Resulting query:
SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
In the resulting query, the brackets surrounding the OR conjunction are lost.
> EJBQL query doesn't preserve grouping by brackets
> -------------------------------------------------
>
> Key: CAY-1371
> URL: https://issues.apache.org/jira/browse/CAY-1371
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0RC2
> Reporter: Andreas Hartmann
>
> EJBQL statement:
> SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
> Resulting query:
> SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
> In the resulting query, the brackets surrounding the OR clause are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping by
brackets
Posted by "Andreas Hartmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Hartmann updated CAY-1371:
----------------------------------
Attachment: CAY-1371.patch
Here's a quick fix that solves the issue for me. I'm not familiar enough with the internals to provide a sophisticated patch.
> EJBQL query doesn't preserve grouping by brackets
> -------------------------------------------------
>
> Key: CAY-1371
> URL: https://issues.apache.org/jira/browse/CAY-1371
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0RC2
> Reporter: Andreas Hartmann
> Attachments: CAY-1371.patch
>
>
> EJBQL statement:
> SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
> Resulting query:
> SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
> In the resulting query, the brackets surrounding the OR clause are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (CAY-1371) EJBQL query doesn't preserve grouping by
brackets
Posted by "Andrey Razumovsky (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Razumovsky closed CAY-1371.
----------------------------------
Resolution: Fixed
Fix Version/s: 3.0RC2
Assignee: Andrey Razumovsky
> EJBQL query doesn't preserve grouping by brackets
> -------------------------------------------------
>
> Key: CAY-1371
> URL: https://issues.apache.org/jira/browse/CAY-1371
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0RC2
> Reporter: Andreas Hartmann
> Assignee: Andrey Razumovsky
> Fix For: 3.0RC2
>
> Attachments: 1371.txt, CAY-1371.patch
>
>
> EJBQL statement:
> SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
> Resulting query:
> SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
> In the resulting query, the brackets surrounding the OR clause are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping by brackets
Posted by Andrus Adamchik <an...@objectstyle.org>.
>> 4.6.6 Operators and Operator Precedence
>> The operators are listed below in order of *decreasing precedence*.
>> ...
>> • Logical operators:
>> NOT
>> AND
>> OR
Ok. It is not clear from the spec whether "decreasing precedence" is
between each bullet in the list or whether this is also within each
bulleted section. But from the BNF (and our parser), I'd take your
interpretation (e.g. "and" expressions are always grouped before "or"
is applied to groups). So then everything makes sense.
Beats me why the authors could not write it explicitly like this, but
anyways... http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html
>>
>> And what about jjtGetParent()?
This is the correct method. Generated by JavaCC, so it looks ugly like
that, still that's the one.
So +1 for the patch.
Andrus
On Jan 24, 2010, at 1:11 PM, Andrey Razumovsky wrote:
> On the last lines, I meant
> a or b and c -- will translate to --> a or b and c, while
> (a or b) and c -- will translate to --> (a or b) and c.
>
> So brackets only when needed
>
>
> 2010/1/24 Andrey Razumovsky <ra...@gmail.com>
>
>> 4.6.6 Operators and Operator Precedence
>> The operators are listed below in order of *decreasing precedence*.
>> ...
>> • Logical operators:
>> NOT
>> AND
>> OR
>>
>> So e.g.
>> a or b and c
>> equals to
>> a or (b and c)
>>
>> Actually it's the same in any language, e.g. in Java.
>> currently our translator has no notion of brackets around
>> statements at
>> all. We could insert them everywhere (like in Andreas's patch) -
>> but it's
>> cleaner insert them only when needed. So
>> a or b and c -- will translate to --> a or (b and c), while
>> a and b and c -- will translate to --> a and b and c.
>>
>> And what about jjtGetParent()?
>>
>> 2010/1/24 Andrus Adamchik <an...@objectstyle.org>
>>
>> As I said, I don't understand 'needBracket' logic.
>>>
>>> Per Andreas's example, the parser already does the correct
>>> grouping based
>>> on user specified parentheses. So all we need to do is to eagerly
>>> place "("
>>> and ")" around each conditional node. So Andreas's patch was doing
>>> the right
>>> thing (of course it also needed handling of AND and NOT).
>>>
>>> And that's what we are already doing for SelectQuery qualifiers.
>>> Although
>>> IIRC we have a "flattenning" algorithm to skip parentheses in
>>> uniformly
>>> joined 3+ term conditions.. Was that the intention of
>>> 'needBracket'?.
>>>
>>> Andrus
>>>
>>>
>>> On Jan 24, 2010, at 12:39 PM, Andrus Adamchik wrote:
>>>
>>> Where does the notion of priority come from? Logically (and from the
>>>> spec) OR/AND/NOT all have the same priority.
>>>>
>>>> Andrus
>>>>
>>>> On Jan 24, 2010, at 12:02 PM, Andrey Razumovsky (JIRA) wrote:
>>>>
>>>> Andrey Razumovsky updated CAY-1371:
>>>>> -----------------------------------
>>>>>
>>>>> Attachment: 1371.txt
>>>>>
>>>>> Patch that fixes the issue. Not committing it just yet, because
>>>>> I'm not
>>>>> sure about patterns of expression processing. Is it correct to
>>>>> call
>>>>> jjtGetParent() ? If so, why isn't there a method with more
>>>>> suitable name?
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> Andrey
>>
>
>
>
> --
> Andrey
Re: [jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping
by brackets
Posted by Andrey Razumovsky <ra...@gmail.com>.
On the last lines, I meant
a or b and c -- will translate to --> a or b and c, while
(a or b) and c -- will translate to --> (a or b) and c.
So brackets only when needed
2010/1/24 Andrey Razumovsky <ra...@gmail.com>
> 4.6.6 Operators and Operator Precedence
> The operators are listed below in order of *decreasing precedence*.
> ...
> • Logical operators:
> NOT
> AND
> OR
>
> So e.g.
> a or b and c
> equals to
> a or (b and c)
>
> Actually it's the same in any language, e.g. in Java.
> currently our translator has no notion of brackets around statements at
> all. We could insert them everywhere (like in Andreas's patch) - but it's
> cleaner insert them only when needed. So
> a or b and c -- will translate to --> a or (b and c), while
> a and b and c -- will translate to --> a and b and c.
>
> And what about jjtGetParent()?
>
> 2010/1/24 Andrus Adamchik <an...@objectstyle.org>
>
> As I said, I don't understand 'needBracket' logic.
>>
>> Per Andreas's example, the parser already does the correct grouping based
>> on user specified parentheses. So all we need to do is to eagerly place "("
>> and ")" around each conditional node. So Andreas's patch was doing the right
>> thing (of course it also needed handling of AND and NOT).
>>
>> And that's what we are already doing for SelectQuery qualifiers. Although
>> IIRC we have a "flattenning" algorithm to skip parentheses in uniformly
>> joined 3+ term conditions.. Was that the intention of 'needBracket'?.
>>
>> Andrus
>>
>>
>> On Jan 24, 2010, at 12:39 PM, Andrus Adamchik wrote:
>>
>> Where does the notion of priority come from? Logically (and from the
>>> spec) OR/AND/NOT all have the same priority.
>>>
>>> Andrus
>>>
>>> On Jan 24, 2010, at 12:02 PM, Andrey Razumovsky (JIRA) wrote:
>>>
>>> Andrey Razumovsky updated CAY-1371:
>>>> -----------------------------------
>>>>
>>>> Attachment: 1371.txt
>>>>
>>>> Patch that fixes the issue. Not committing it just yet, because I'm not
>>>> sure about patterns of expression processing. Is it correct to call
>>>> jjtGetParent() ? If so, why isn't there a method with more suitable name?
>>>>
>>>
>>>
>>>
>>
>
>
> --
> Andrey
>
--
Andrey
Re: [jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping
by brackets
Posted by Andrey Razumovsky <ra...@gmail.com>.
4.6.6 Operators and Operator Precedence
The operators are listed below in order of *decreasing precedence*.
...
• Logical operators:
NOT
AND
OR
So e.g.
a or b and c
equals to
a or (b and c)
Actually it's the same in any language, e.g. in Java.
currently our translator has no notion of brackets around statements at all.
We could insert them everywhere (like in Andreas's patch) - but it's cleaner
insert them only when needed. So
a or b and c -- will translate to --> a or (b and c), while
a and b and c -- will translate to --> a and b and c.
And what about jjtGetParent()?
2010/1/24 Andrus Adamchik <an...@objectstyle.org>
> As I said, I don't understand 'needBracket' logic.
>
> Per Andreas's example, the parser already does the correct grouping based
> on user specified parentheses. So all we need to do is to eagerly place "("
> and ")" around each conditional node. So Andreas's patch was doing the right
> thing (of course it also needed handling of AND and NOT).
>
> And that's what we are already doing for SelectQuery qualifiers. Although
> IIRC we have a "flattenning" algorithm to skip parentheses in uniformly
> joined 3+ term conditions.. Was that the intention of 'needBracket'?.
>
> Andrus
>
>
> On Jan 24, 2010, at 12:39 PM, Andrus Adamchik wrote:
>
> Where does the notion of priority come from? Logically (and from the spec)
>> OR/AND/NOT all have the same priority.
>>
>> Andrus
>>
>> On Jan 24, 2010, at 12:02 PM, Andrey Razumovsky (JIRA) wrote:
>>
>> Andrey Razumovsky updated CAY-1371:
>>> -----------------------------------
>>>
>>> Attachment: 1371.txt
>>>
>>> Patch that fixes the issue. Not committing it just yet, because I'm not
>>> sure about patterns of expression processing. Is it correct to call
>>> jjtGetParent() ? If so, why isn't there a method with more suitable name?
>>>
>>
>>
>>
>
--
Andrey
Re: [jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping by brackets
Posted by Andrus Adamchik <an...@objectstyle.org>.
As I said, I don't understand 'needBracket' logic.
Per Andreas's example, the parser already does the correct grouping
based on user specified parentheses. So all we need to do is to
eagerly place "(" and ")" around each conditional node. So Andreas's
patch was doing the right thing (of course it also needed handling of
AND and NOT).
And that's what we are already doing for SelectQuery qualifiers.
Although IIRC we have a "flattenning" algorithm to skip parentheses in
uniformly joined 3+ term conditions.. Was that the intention of
'needBracket'?.
Andrus
On Jan 24, 2010, at 12:39 PM, Andrus Adamchik wrote:
> Where does the notion of priority come from? Logically (and from the
> spec) OR/AND/NOT all have the same priority.
>
> Andrus
>
> On Jan 24, 2010, at 12:02 PM, Andrey Razumovsky (JIRA) wrote:
>
>> Andrey Razumovsky updated CAY-1371:
>> -----------------------------------
>>
>> Attachment: 1371.txt
>>
>> Patch that fixes the issue. Not committing it just yet, because I'm
>> not sure about patterns of expression processing. Is it correct to
>> call jjtGetParent() ? If so, why isn't there a method with more
>> suitable name?
>
>
Re: [jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping by brackets
Posted by Andrus Adamchik <an...@objectstyle.org>.
Where does the notion of priority come from? Logically (and from the
spec) OR/AND/NOT all have the same priority.
Andrus
On Jan 24, 2010, at 12:02 PM, Andrey Razumovsky (JIRA) wrote:
> Andrey Razumovsky updated CAY-1371:
> -----------------------------------
>
> Attachment: 1371.txt
>
> Patch that fixes the issue. Not committing it just yet, because I'm
> not sure about patterns of expression processing. Is it correct to
> call jjtGetParent() ? If so, why isn't there a method with more
> suitable name?
[jira] Updated: (CAY-1371) EJBQL query doesn't preserve grouping by
brackets
Posted by "Andrey Razumovsky (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Razumovsky updated CAY-1371:
-----------------------------------
Attachment: 1371.txt
Patch that fixes the issue. Not committing it just yet, because I'm not sure about patterns of expression processing. Is it correct to call jjtGetParent() ? If so, why isn't there a method with more suitable name?
> EJBQL query doesn't preserve grouping by brackets
> -------------------------------------------------
>
> Key: CAY-1371
> URL: https://issues.apache.org/jira/browse/CAY-1371
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0RC2
> Reporter: Andreas Hartmann
> Attachments: 1371.txt, CAY-1371.patch
>
>
> EJBQL statement:
> SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
> Resulting query:
> SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
> In the resulting query, the brackets surrounding the OR clause are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (CAY-1371) EJBQL query doesn't
preserve grouping by brackets
Posted by "Andreas Hartmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803299#action_12803299 ]
Andreas Hartmann edited comment on CAY-1371 at 1/21/10 2:25 PM:
----------------------------------------------------------------
The error seems to occur when the SQL string is built. The hierarchy of the EJBQL expression looks good:
Select
SelectClause
SelectExpressions
SelectExpression
Aggregate
Count
Identifier [t]
From
FromItem
AbstractSchemaName
IdentificationVariable [User]
Identifier [t]
Where
And
Equals
Path
Identifier [t]
IdentificationVariable [language]
IdentificationVariable [code]
StringLiteral ['fr']
Or
Like
Upper
Path
Identifier [t]
IdentificationVariable [email]
PatternValue
StringLiteral ['%ANDREAS.HARTMANN@GMAIL.COM%']
Like
Upper
Path
Identifier [t]
IdentificationVariable [email]
PatternValue
StringLiteral ['%NOBBY@MACBAY.DE%']
was (Author: andreas@apache.org):
The error seems to occur when the SQL string is built. The hierarchy of the EJBQL expression looks good:
<pre>
Select
SelectClause
SelectExpressions
SelectExpression
Aggregate
Count
Identifier [t]
From
FromItem
AbstractSchemaName
IdentificationVariable [User]
Identifier [t]
Where
And
Equals
Path
Identifier [t]
IdentificationVariable [language]
IdentificationVariable [code]
StringLiteral ['fr']
Or
Like
Upper
Path
Identifier [t]
IdentificationVariable [email]
PatternValue
StringLiteral ['%ANDREAS.HARTMANN@GMAIL.COM%']
Like
Upper
Path
Identifier [t]
IdentificationVariable [email]
PatternValue
StringLiteral ['%NOBBY@MACBAY.DE%']
</pre>
> EJBQL query doesn't preserve grouping by brackets
> -------------------------------------------------
>
> Key: CAY-1371
> URL: https://issues.apache.org/jira/browse/CAY-1371
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0RC2
> Reporter: Andreas Hartmann
>
> EJBQL statement:
> SELECT object(t) FROM User t WHERE (t.language.code = 'fr') AND ((upper(t.email) LIKE '%ANDREAS.HARTMANN@GMAIL.COM%') OR (upper(t.email) LIKE '%NOBBY@MACBAY.DE%'))
> Resulting query:
> SELECT COUNT(*) AS sc0 FROM public.user t0 INNER JOIN public.language t1 ON (t0.language = t1.code) WHERE t1.code = ? AND {fn UCASE( t0.email)} LIKE ? OR {fn UCASE( t0.email)} LIKE ?
> In the resulting query, the brackets surrounding the OR clause are lost.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.