Skip to content

Commit

Permalink
JCR-2923 SQL2 parser: improved error message for ambiguous properties…
Browse files Browse the repository at this point in the history
… in joins

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/trunk@1083722 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
thomasmueller committed Mar 21, 2011
1 parent c638e38 commit d8b9ac9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import javax.jcr.query.qom.Source;
import javax.jcr.version.VersionException;
import junit.framework.TestCase;
import org.apache.jackrabbit.commons.query.sql2.Parser;
import org.apache.jackrabbit.commons.query.sql2.QOMFormatter;
import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver;
Expand All @@ -55,7 +56,7 @@
*/
public class ParserTest extends TestCase {

protected Parser parser;
protected org.apache.jackrabbit.commons.query.sql2.Parser parser;

protected Random random = new Random();

Expand Down Expand Up @@ -84,6 +85,7 @@ public Column[] getColumns() {
}

public void bindValue(String varName, Value value) throws IllegalArgumentException, RepositoryException {
// ignore
}

public QueryResult execute() throws InvalidQueryException, RepositoryException {
Expand All @@ -107,9 +109,11 @@ public String getStoredQueryPath() throws ItemNotFoundException, RepositoryExcep
}

public void setLimit(long limit) {
// ignore
}

public void setOffset(long offset) {
// ignore
}

public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException,
Expand Down Expand Up @@ -171,11 +175,14 @@ public void testParseScript() throws Exception {
fuzz(line);
} catch (Exception e) {
line = reader.readLine();
String message = e.getMessage();
message = message.replace('\n', ' ');
if (line == null || !line.startsWith("> exception")) {
e.printStackTrace();
assertTrue("Unexpected exception for query " + query + ": "
+ e, false);
}
assertEquals("Expected exception message: " + message, "> exception: " + message, line);
}
}
reader.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ select x.*, x.id as i, y.*, y.name from test as x inner join test as y on x.id=y

#errors
select * from parent as p inner join child as c on issamenode(p, c, a/b)
> exception
> exception: Query: select * from parent as p inner join child as c on issamenode(p, c, a/(*)b); expected: )
select * from parent as p inner join child as c on issamenode(p, c, d, e)
> exception
> exception: Query: select * from parent as p inner join child as c on issamenode(p, c, d,(*)e); expected: )
select * from
> exception
> exception: Query: select * fro(*)m; expected: a token
select * from parent as p inner join child as c on ischildnode(p, c, a)
> exception
> exception: Query: select * from parent as p inner join child as c on ischildnode(p, c,(*)a); expected: )
select * from parent as p inner join child as c on isdescendantnode(p)
> exception
> exception: Query: select * from parent as p inner join child as c on isdescendantnode(p(*)); expected: ,
select * from parent as p inner join child as c on isdescendantnode(a, b, c)
> exception
> exception: Query: select * from parent as p inner join child as c on isdescendantnode(a, b,(*)c); expected: )
select id from parent inner join child on parent.id=child.parentid
> exception: Query: select id(*)from parent inner join child on parent.id=child.parentid; expected: Need to specify the selector name for "id" because the query contains more than one selector.

0 comments on commit d8b9ac9

Please sign in to comment.