1

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
)
tzrlk
  • 848
  • 1
  • 13
  • 30
  • 1
    Does: `SELECT * FROM [cq:PageContent] AS page WHERE ISDESCENDANTNODE(page, '/content') AND ( ( page.[offTime] IS NOT NULL AND LENGTH(page.[onTime]) < 29 ) )` work? – femtoRgon Nov 04 '13 at 16:34
  • Yup. The indentation, whitespace, and non-critical parentheses have no effect on the query result. – tzrlk Nov 04 '13 at 20:00
  • 1
    I was more pursuing whether querying with the `page.[onTime]` clause alone, rather than `page.[offTime]`, worked (comments don't allow multi-line code blocks). – femtoRgon Nov 04 '13 at 20:09
  • Interesting. It appears that using parentheses in the expression, and having an OR clause seems to be causing the problem more than multiple uses of LENGTH. – tzrlk Nov 04 '13 at 20:20

0 Answers0