[
https://issues.apache.org/jira/browse/JDO-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14263490#comment-14263490
]
Andy Jefferson commented on JDO-650:
------------------------------------
The only problem i have with that is that you now have a *relational field* in
the CASE. JPA defines a CASE scalar/value expression to be for
scalar_expression ::= simple_arithmetic_expression | string_primary |
enum_primary |
datetime_primary | boolean_primary | case_expression |
entity_type_expression
That is, for simple fields/values only. i.e ones that don't start to introduce
joins in the resultant SQL, yet the test goes beyond that. The test
SELECT FROM org.apache.jdo.tck.pc.company.Employee
WHERE (IF (this.manager == null) this.mentor.department
ELSE this.manager.department) == this.department
ORDER BY this.personid
results in
SELECT DISTINCT A0.BIRTHDATE,A0.FIRSTNAME,A0.LASTNAME,A0.PERSONID AS
NUCORDER0,A0.HIREDATE,A0.WEEKLYHOURS,A0.DISCRIMINATOR
FROM APPLICATIONIDENTITY0.PERSONS A0
LEFT OUTER JOIN APPLICATIONIDENTITY0.PERSONS B0 ON A0.MENTOR = B0.PERSONID
LEFT OUTER JOIN APPLICATIONIDENTITY0.DEPARTMENTS C0 ON B0.DEPARTMENT = C0.ID
LEFT OUTER JOIN APPLICATIONIDENTITY0.PERSONS D0 ON A0.MANAGER = D0.PERSONID
LEFT OUTER JOIN APPLICATIONIDENTITY0.DEPARTMENTS E0 ON D0.DEPARTMENT = E0.ID
WHERE ((A0.DISCRIMINATOR = 'org.apache.jdo.tck.pc.company.FullTimeEmployee' OR
A0.DISCRIMINATOR = 'org.apache.jdo.tck.pc.company.PartTimeEmployee'))
AND (CASE WHEN A0.MANAGER IS NULL THEN C0.ID ELSE E0.ID END) = A0.DEPARTMENT
ORDER BY NUCORDER0
This isn't the sort of thing I'd expect SQL to handle reliably, or what adding
this feature was intended for (IMHO).
> Support for conditional operator ? : in JDOQL
> ---------------------------------------------
>
> Key: JDO-650
> URL: https://issues.apache.org/jira/browse/JDO-650
> Project: JDO
> Issue Type: New Feature
> Components: specification, tck
> Affects Versions: JDO 2 maintenance release 2 (2.2)
> Reporter: Michael Bouschen
> Assignee: Michael Bouschen
> Fix For: JDO 3.1
>
>
> JDOQL should support the Java conditional operator ? :, e.g. salary >= 1000.0
> ? salary : salary * 1.1
> The conditional operator can be mapped to the CASE-expression in SQL: CASE
> WHEN condition THEN thenExpr ELSE elseExpr END. Are there any issues with
> non-SQL datastores when supporting the conditional operator?
> Another question: which part of a JDOQL query can include a conditional
> expression? I propose the query filter, the having clause and the result
> specification.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)