Cannot query with 2 relationship predicates
-------------------------------------------
Key: ARTIF-656
URL:
https://issues.jboss.org/browse/ARTIF-656
Project: Artificer
Issue Type: Bug
Reporter: Brett Meyer
Assignee: Brett Meyer
Example:
{code}
/s-ramp/wsdl/Part[relatedDocument[@uuid = '%1$s'] and element]
{code}
That currently results in something like:
{code}
SELECT artifact1.* FROM [sramp:baseArtifactType] AS artifact1
INNER JOIN [sramp:relationship] AS relationship2 ON ISCHILDNODE(relationship2,artifact1)
INNER JOIN [sramp:target] AS target3 ON ISCHILDNODE(target3,relationship2)
INNER JOIN [sramp:baseArtifactType] AS artifact4 ON target3.[sramp:targetArtifact] =
artifact4.[jcr:uuid]
INNER JOIN [sramp:relationship] AS relationship5 ON ISCHILDNODE(relationship5,artifact1)
WHERE
artifact1.[sramp:artifactType] = 'Part'
AND relationship2.[sramp:relationshipType] = 'relatedDocument'
AND artifact4.[sramp:uuid] = 'cea13510-e7a6-4195-a18e-c091eb5a939e'
AND relationship5.[sramp:relationshipType] = 'element'
AND ISDESCENDANTNODE([sramp:baseArtifactType],'/s-ramp'
{code}
Since we use an artifact -> relationship -> target structure, and since ModeShape
doesn't allow you to use the selectors transitively (ie, can't use
"artifact1" in a subselect), inner joins were the method used. Each time a
relationship predicate is hit, the parser assumes "I need to join and add a
condition".
Forgetting the parser, for a moment, I'm not sure what the eventual query should look
like...