You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Alexander Karpov (JIRA)" <ji...@apache.org> on 2010/09/28 12:05:32 UTC

[jira] Created: (OPENJPA-1817) JPQL doens't support ORDER BY UPPER(fieldname)

JPQL doens't support ORDER BY UPPER(fieldname)
----------------------------------------------

                 Key: OPENJPA-1817
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1817
             Project: OpenJPA
          Issue Type: Improvement
            Reporter: Alexander Karpov
            Priority: Minor


I tried to solve it myself

I have changed
\openjpa\openjpa-kernel\src\main\jjtree\org\apache\openjpa\kernel\jpql\JPQL.jjt
void orderby_extension() #ORDERBYEXTENSION : { }
{
    aggregate_select_expression()
}
to
void orderby_extension() #ORDERBYEXTENSION : { }
{
    aggregate_select_expression() | upper()
} 

But afraid that it might break any other cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1817) JPQL doens't support ORDER BY UPPER(fieldname)

Posted by "Catalina Wei (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1817?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12915925#action_12915925 ] 

Catalina Wei commented on OPENJPA-1817:
---------------------------------------

There are lots of improvement that can be done to JPQL.jjt, but I think we would want to conform with JPA Spec.

You can rewrite the JPQL query  to using result_variable as the order_item, for example:

     select e.name, upper(e.name) from Emp e order by upper(e.name)  ==> causes syntax error

Rewrite it as the following should work:

     select e.name, upper(e.name) as uname from Emp e order by uname




> JPQL doens't support ORDER BY UPPER(fieldname)
> ----------------------------------------------
>
>                 Key: OPENJPA-1817
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1817
>             Project: OpenJPA
>          Issue Type: Improvement
>            Reporter: Alexander Karpov
>            Priority: Minor
>
> I tried to solve it myself
> I have changed
> \openjpa\openjpa-kernel\src\main\jjtree\org\apache\openjpa\kernel\jpql\JPQL.jjt
> void orderby_extension() #ORDERBYEXTENSION : { }
> {
>     aggregate_select_expression()
> }
> to
> void orderby_extension() #ORDERBYEXTENSION : { }
> {
>     aggregate_select_expression() | upper()
> } 
> But afraid that it might break any other cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1817) JPQL doens't support ORDER BY UPPER(fieldname)

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1817?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12915855#action_12915855 ] 

Fay Wang commented on OPENJPA-1817:
-----------------------------------

Per JPA spec (Section4.14 BNF):

orderby_clause ::= ORDER BY orderby_item {, orderby_item}*
orderby_item ::= state_field_path_expression | result_variable [ ASC | DESC ]

and upper(fieldname) is a functions_returning_strings:

functions_returning_strings ::=
CONCAT(string_primary, string_primary {, string_primary}*) |
SUBSTRING(string_primary,
simple_arithmetic_expression [, simple_arithmetic_expression]) |
TRIM([[trim_specification] [trim_character] FROM] string_primary) |
LOWER(string_primary) |
UPPER(string_primary)

The functions_returning_strings is not allowed in orderby_clause. 




> JPQL doens't support ORDER BY UPPER(fieldname)
> ----------------------------------------------
>
>                 Key: OPENJPA-1817
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1817
>             Project: OpenJPA
>          Issue Type: Improvement
>            Reporter: Alexander Karpov
>            Priority: Minor
>
> I tried to solve it myself
> I have changed
> \openjpa\openjpa-kernel\src\main\jjtree\org\apache\openjpa\kernel\jpql\JPQL.jjt
> void orderby_extension() #ORDERBYEXTENSION : { }
> {
>     aggregate_select_expression()
> }
> to
> void orderby_extension() #ORDERBYEXTENSION : { }
> {
>     aggregate_select_expression() | upper()
> } 
> But afraid that it might break any other cases.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.