I've been trying to run a particular query on my JCR repository (AEM), and for some reason, I'm not able to use the LENGTH function more than once. This means that the following query runs perfectly fine:
SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content') AND (
( page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 )
)
But if I add another condition to the block:
SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content') AND (
( page.[onTime] IS NOT NULL AND LENGTH(page.[onTime]) < 29 ) OR
( page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 )
)
It throws the following exception (stacktrace omitted):
javax.jcr.UnsupportedRepositoryOperationException: Unknown operand type: LENGTH(page.onTime)
I can work around the issue, but only in an annoyingly obtuse way that involves code bloat. Any ideas? This really seems like something a query language should just handle.
---------- UPDATES ----------
It appears that running the following version of the query compiles fine, but results the same error:
SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content')
AND ( page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 )
OR ( page.[onTime] IS NOT NULL AND LENGTH(page.[onTime]) < 29 )
Same with:
SELECT * FROM [cq:PageContent] AS page
WHERE ISDESCENDANTNODE(page, '/content') AND (
page.[onTime] IS NOT NULL AND LENGTH(page.[onTime]) < 29 OR
page.[offTime] IS NOT NULL AND LENGTH(page.[offTime]) < 29 OR
page.[jcr:created] IS NOT NULL AND LENGTH(page.[jcr:created]) < 29
)