Wrong SQL-2 parsing
-------------------
Key: JCR-2704
URL: https://issues.apache.org/jira/browse/JCR-2704
Project: Jackrabbit Content Repository
Issue Type: Bug
Components: jackrabbit-jcr-commons, query, sql
Affects Versions: 2.1.0, 2.0.0
Reporter: Benjamin Papez
With the QOM factory I created the following constraints:
And
├ ChildNode
└ Or
├ Not
│ └ PropertyExistence
└ Comparison
The created statement in the Query implementation object looks like this:
SELECT news.* FROM [jnt:news] AS news WHERE ISCHILDNODE(news,
[/sites/jcrQueryTest/home/page8/news]) AND (NOT news.[jcr:language] IS NOT NULL
OR news.[jcr:language] = 'en') ORDER BY news.[jcr:created] DESC
Here it would already be better if the QOMFormatter would translate Not ->
PropertyExistence to "news.[jcr:language] IS NULL" instead of "NOT
news.[jcr:language] IS NOT NULL" .
Anyway, for testing I took the above query statement and called:
Query q = queryManager.createQuery(queryStatement,
Query.JCR_SQL2)
and then I looked at the created statement and it converts to:
SELECT news.* FROM [jnt:news] AS news WHERE ISCHILDNODE(news,
[/sites/jcrQueryTest/home/page8/news]) AND NOT (news.[jcr:language] IS NOT NULL
OR news.[jcr:language] = 'en') ORDER BY news.[jcr:created] DESC
...AND (NOT news.[jcr:language] IS NOT NULL OR news.[jcr:language] = 'en')...
got converted to
...AND NOT (news.[jcr:language] IS NOT NULL OR news.[jcr:language] = 'en') ...
This looks like a bug in the Parser.
Furthermore if I take the following query:
SELECT news.* FROM [jnt:news] AS news WHERE ISDESCENDANTNODE(news,
[/sites/jcrQueryTest]) AND (LENGTH(news.[j:nodename]) > 100 OR news.[date] >
'+2001-01-01T01:02:03.000Z') AND (NOT news.[jcr:language] IS NOT NULL OR
news.[jcr:language] = 'en')
and after queryManager.createQuery(queryStatement, Query.JCR_SQL2) the
statement will be converted to:
SELECT news.* FROM [jnt:news] AS news WHERE ISDESCENDANTNODE(news,
[/sites/jcrQueryTest]) AND (LENGTH(news.[j:nodename]) > 100 OR news.date >
'+2001-01-01T01:02:03.000Z') AND (NOT news.[jcr:language] IS NOT NULL OR
news.[jcr:language] = 'en')
So, suddenly the brackets around date are removed:
...OR news.[date] > '+2001-...
becomes
OR news.date > '+2001-
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.