You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org> on 2008/02/25 09:46:16 UTC

[jira] Created: (CAY-990) Arithmetic operators in EJBQL

Arithmetic operators in EJBQL
-----------------------------

                 Key: CAY-990
                 URL: https://issues.apache.org/cayenne/browse/CAY-990
             Project: Cayenne
          Issue Type: Task
          Components: Cayenne Core Library
    Affects Versions: 3.0
            Reporter: Andrus Adamchik
            Assignee: Andrus Adamchik
             Fix For: 3.0


Implement arithmetic operators in EJBQL.

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


[jira] Commented: (CAY-990) Arithmetic operators in EJBQL

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751#action_12751 ] 

Andrus Adamchik commented on CAY-990:
-------------------------------------

DataContextEJBQLConditionsTest.testArithmetics() works on MySQL, however HSQLDB throws:

NFO: SELECT t0.PAINTING_TITLE AS ec0_0, t0.ARTIST_ID AS ec0_1, t0.PAINTING_DESCRIPTION AS ec0_2, t0.ESTIMATED_PRICE AS ec0_3, t0.GALLERY_ID AS ec0_4, t0.PAINTING_ID AS ec0_5 FROM PAINTING t0 WHERE t0.ESTIMATED_PRICE < ( ? + ( ? * ?)) [bind: 1:1, 2:-4.0, 3:-1000.0]
Feb 25, 2008 10:43:17 AM org.apache.cayenne.access.QueryLogger logQueryError
INFO: *** error.
java.sql.SQLException: Unresolved parameter type : as both operands of aritmetic operator in statement [SELECT t0.PAINTING_TITLE AS ec0_0, t0.ARTIST_ID AS ec0_1, t0.PAINTING_DESCRIPTION AS ec0_2, t0.ESTIMATED_PRICE AS ec0_3, t0.GALLERY_ID AS ec0_4, t0.PAINTING_ID AS ec0_5 FROM PAINTING t0 WHERE t0.ESTIMATED_PRICE < ( ? + ( ? * ?))]
	at org.hsqldb.jdbc.Util.throwError(Unknown Source)
	at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
	at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
	at org.apache.cayenne.conn.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:274)
	at org.apache.cayenne.conn.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:280)
	at org.apache.cayenne.access.TransactionConnectionDecorator.prepareStatement(TransactionConnectionDecorator.java:179)

(should we do in-memory evaluation for HSQLDB?)

> Arithmetic operators in EJBQL
> -----------------------------
>
>                 Key: CAY-990
>                 URL: https://issues.apache.org/cayenne/browse/CAY-990
>             Project: Cayenne
>          Issue Type: Task
>          Components: Cayenne Core Library
>    Affects Versions: 3.0
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.0
>
>
> Implement arithmetic operators in EJBQL.

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


[jira] Updated: (CAY-990) HSQLDB: Arithmetic operators in EJBQL

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
     [ https://issues.apache.org/cayenne/browse/CAY-990?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik updated CAY-990:
--------------------------------

    Summary: HSQLDB: Arithmetic operators in EJBQL  (was: Arithmetic operators in EJBQL)

> HSQLDB: Arithmetic operators in EJBQL
> -------------------------------------
>
>                 Key: CAY-990
>                 URL: https://issues.apache.org/cayenne/browse/CAY-990
>             Project: Cayenne
>          Issue Type: Task
>          Components: Cayenne Core Library
>    Affects Versions: 3.0
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.0
>
>
> Implement arithmetic operators in EJBQL.

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


[jira] Commented: (CAY-990) HSQLDB: Arithmetic operators in EJBQL

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931#action_12931 ] 

Andrus Adamchik commented on CAY-990:
-------------------------------------

Thanks for clarification. We'll try it with casts.

> HSQLDB: Arithmetic operators in EJBQL
> -------------------------------------
>
>                 Key: CAY-990
>                 URL: https://issues.apache.org/cayenne/browse/CAY-990
>             Project: Cayenne
>          Issue Type: Task
>          Components: Cayenne Core Library
>    Affects Versions: 3.0
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.0
>
>
> Implement arithmetic operators in EJBQL.

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


[jira] Commented: (CAY-990) HSQLDB: Arithmetic operators in EJBQL

Posted by "Campbell Boucher-Burnet (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930#action_12930 ] 

Campbell Boucher-Burnet commented on CAY-990:
---------------------------------------------

Try using SQL casts to disambiguate the expression... like:

WHERE  t0.ESTIMATED_PRICE < ( cast(? as decimal) + ( cast(? as decimal) * cast(? as decimal)))

Casting only one of the parameter markers may be enough, as the type of the rest may then be inferred.

However, its been a while sine I was deep in the code.

The point is, it states in the SQL 200n specification that there are definite cases that are to be considered ambiguous, and back in the early 2000s, based on the spec at the time, I wrote much of the 1.7 to early 1.8 HSQLDB expression evaluation code that handled ambiguity under parameter markers, as part of my work refactoring the entire codebase to provide an efficient precompiled parametric statement facility

A for instance in in the ambiguous expression category is an SQL condition likeL "? in (?,?,?,?)"... without explicit casts, at least one term must be resolvable to an SQL literal that has an inferable type in such an expression, for instance  "'test' in (?,?,?,?) " or "? in (?,?,1+4,?)"

What suprises me is that the types of the parameter markers are not inferred automatically in the parse/resolve phase from t0.ESTIMATED_PRICE, which is certainly an ellible, as it is a simple RHS of a relational operator from which to make the inference from the LHS.

Probably, the exception thrown represents a regression caused by ongoing modification's to the source for the expression resolution facility that cause it to fail to adhere to expending the best possible effort toward resolving parameters by inference.


> HSQLDB: Arithmetic operators in EJBQL
> -------------------------------------
>
>                 Key: CAY-990
>                 URL: https://issues.apache.org/cayenne/browse/CAY-990
>             Project: Cayenne
>          Issue Type: Task
>          Components: Cayenne Core Library
>    Affects Versions: 3.0
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.0
>
>
> Implement arithmetic operators in EJBQL.

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