You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2008/07/23 12:06:12 UTC
svn commit: r679054 -
/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
Author: mreutegg
Date: Wed Jul 23 03:06:12 2008
New Revision: 679054
URL: http://svn.apache.org/viewvc?rev=679054&view=rev
Log:
JCR-1688: Query parser builds invalid parse tree
Modified:
jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java?rev=679054&r1=679053&r2=679054&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java Wed Jul 23 03:06:12 2008
@@ -424,12 +424,8 @@
predicateNode = in;
} else if (type == QueryConstants.OPERATION_NULL
|| type == QueryConstants.OPERATION_NOT_NULL) {
- // create a dummy literal
- ASTLiteral star = new ASTLiteral(JCRSQLParserTreeConstants.JJTLITERAL);
- star.setType(QueryConstants.TYPE_STRING);
- star.setValue("%");
predicateNode = createRelationQueryNode(parent,
- identifier, type, star);
+ identifier, type, null);
} else if (type == QueryConstants.OPERATION_SIMILAR) {
ASTLiteral literal;
if (node.children.length == 1) {
@@ -598,7 +594,9 @@
* @param parent the parent node for the created <code>RelationQueryNode</code>.
* @param propertyName the property name for the relation.
* @param operationType the operation type.
- * @param literal the literal value for the relation.
+ * @param literal the literal value for the relation or
+ * <code>null</code> if the relation does not have a
+ * literal (e.g. IS NULL).
* @return a <code>RelationQueryNode</code>.
* @throws IllegalArgumentException if the literal value does not conform
* to its type. E.g. a malformed String representation of a date.
@@ -609,7 +607,6 @@
ASTLiteral literal)
throws IllegalArgumentException {
- String stringValue = literal.getValue();
RelationQueryNode node = null;
try {
@@ -619,28 +616,31 @@
builder.addLast(propertyName);
relPath = builder.getPath();
}
- if (literal.getType() == QueryConstants.TYPE_DATE) {
+ if (literal == null) {
+ node = factory.createRelationQueryNode(parent, operationType);
+ node.setRelativePath(relPath);
+ } else if (literal.getType() == QueryConstants.TYPE_DATE) {
SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
- Date date = format.parse(stringValue);
+ Date date = format.parse(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setDateValue(date);
} else if (literal.getType() == QueryConstants.TYPE_DOUBLE) {
- double d = Double.parseDouble(stringValue);
+ double d = Double.parseDouble(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setDoubleValue(d);
} else if (literal.getType() == QueryConstants.TYPE_LONG) {
- long l = Long.parseLong(stringValue);
+ long l = Long.parseLong(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setLongValue(l);
} else if (literal.getType() == QueryConstants.TYPE_STRING) {
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
- node.setStringValue(stringValue);
+ node.setStringValue(literal.getValue());
} else if (literal.getType() == QueryConstants.TYPE_TIMESTAMP) {
- Calendar c = ISO8601.parse(stringValue);
+ Calendar c = ISO8601.parse(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setDateValue(c.getTime());