From 5aa7bf1cbaae2b92356f9fcd3c248e63b91e5be9 Mon Sep 17 00:00:00 2001 From: dmfay Date: Mon, 6 Aug 2012 19:53:36 -0400 Subject: [PATCH] JcrSql2QueryParser was downcasting limit when parsing queries with set operations --- .../modeshape/jcr/query/JcrSql2QueryParser.java | 2 +- .../jcr/query/JcrSql2QueryParserTest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/modeshape-jcr/src/main/java/org/modeshape/jcr/query/JcrSql2QueryParser.java b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/JcrSql2QueryParser.java index e56215e..689d24c 100644 --- a/modeshape-jcr/src/main/java/org/modeshape/jcr/query/JcrSql2QueryParser.java +++ b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/JcrSql2QueryParser.java @@ -160,7 +160,7 @@ public class JcrSql2QueryParser extends SqlQueryParser { Operation operation, QueryCommand rightQuery, boolean all ) { - return new JcrSetQuery((JcrQueryCommand)leftQuery, operation, (JcrQueryCommand)rightQuery, all); + return new JcrSetQuery((JcrQueryCommand)leftQuery, operation, (JcrQueryCommand)rightQuery, all, null, JcrLimit.NONE); } protected List columns( List columns ) { diff --git a/modeshape-jcr/src/test/java/org/modeshape/jcr/query/JcrSql2QueryParserTest.java b/modeshape-jcr/src/test/java/org/modeshape/jcr/query/JcrSql2QueryParserTest.java index 80c7b4b..c89100d 100644 --- a/modeshape-jcr/src/test/java/org/modeshape/jcr/query/JcrSql2QueryParserTest.java +++ b/modeshape-jcr/src/test/java/org/modeshape/jcr/query/JcrSql2QueryParserTest.java @@ -65,6 +65,7 @@ import org.modeshape.graph.query.model.Query; import org.modeshape.graph.query.model.QueryCommand; import org.modeshape.graph.query.model.SameNodeJoinCondition; import org.modeshape.graph.query.model.SelectorName; +import org.modeshape.graph.query.model.SetQuery; import org.modeshape.graph.query.model.Source; import org.modeshape.graph.query.model.StaticOperand; import org.modeshape.graph.query.model.TypeSystem; @@ -520,6 +521,13 @@ public class JcrSql2QueryParserTest { // WHERE ... assertThat(query.constraint(), is(nullValue())); } + + @Test + public void shouldParseSetQuery() { + parseSetQuery("SELECT nodes.col1, nodes.col2 FROM table1 AS nodes UNION SELECT edges.col3, edges.col4 FROM table2 AS edges"); + parseSetQuery("SELECT nodes.col1, nodes.col2 FROM table1 AS nodes INTERSECT SELECT edges.col3, edges.col4 FROM table2 AS edges"); + parseSetQuery("SELECT nodes.col1, nodes.col2 FROM table1 AS nodes EXCEPT SELECT edges.col3, edges.col4 FROM table2 AS edges"); + } protected Join isJoin( Source source ) { assertThat(source, is(instanceOf(Join.class))); @@ -606,6 +614,12 @@ public class JcrSql2QueryParserTest { return (Query)command; } + protected SetQuery parseSetQuery( String query ) { + QueryCommand command = parser.parseQuery(query, typeSystem); + assertThat(command, is(instanceOf(SetQuery.class))); + return (SetQuery)command; + } + protected QueryCommand parseCommand( String query ) { return parser.parseQuery(query, typeSystem); } -- 1.7.8.msysgit.0