jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r191426 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
Date Mon, 20 Jun 2005 08:57:56 GMT
Author: mreutegg
Date: Mon Jun 20 01:57:55 2005
New Revision: 191426

URL: http://svn.apache.org/viewcvs?rev=191426&view=rev
Log:
JCR-139: Query for name literal without namespace fails
- coerce string literal to name as soon as it appears as a valid name
- changed coercing behaviour to only work on operations which are not ranges (eq, ne)

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=191426&r1=191425&r2=191426&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
Mon Jun 20 01:57:55 2005
@@ -49,6 +49,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.RangeQuery;
 import org.apache.lucene.search.TermQuery;
+import org.apache.xerces.util.XMLChar;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
@@ -518,12 +519,14 @@
                 stringValues[0] = LongField.longToString(node.getLongValue());
                 break;
             case QueryConstants.TYPE_STRING:
-                if (node.getOperation() == QueryConstants.OPERATION_LIKE
-                        || node.getOperation() == QueryConstants.OPERATION_NULL
-                        || node.getOperation() == QueryConstants.OPERATION_NOT_NULL) {
-                    stringValues[0] = node.getStringValue();
-                } else {
+                if (node.getOperation() == QueryConstants.OPERATION_EQ_GENERAL
+                        || node.getOperation() == QueryConstants.OPERATION_EQ_VALUE
+                        || node.getOperation() == QueryConstants.OPERATION_NE_GENERAL
+                        || node.getOperation() == QueryConstants.OPERATION_NE_VALUE) {
+                    // only use coercing on non-range operations
                     stringValues = getStringValues(node.getProperty(), node.getStringValue());
+                } else {
+                    stringValues[0] = node.getStringValue();
                 }
                 break;
             case QueryConstants.TYPE_POSITION:
@@ -781,19 +784,22 @@
                 } catch (Exception e) {
                     // not a path
                 }
-            } else if (literal.indexOf(':') > -1) {
+            } else if (XMLChar.isValidName(literal)) {
                 // might be a name
                 try {
                     values.add(nsMappings.translatePropertyName(literal, session.getNamespaceResolver()));
                     log.debug("Coerced " + literal + " into NAME.");
+                    // also add literal as string value as is
+                    values.add(literal);
                 } catch (Exception e) {
                     // not a name
-                    // is it a date?
-                    Calendar c = ISO8601.parse(literal);
-                    if (c != null) {
-                        values.add(DateField.timeToString(c.getTimeInMillis()));
-                        log.debug("Coerced " + literal + " into DATE.");
-                    }
+                }
+            } else if (literal.indexOf(':') > -1) {
+                // is it a date?
+                Calendar c = ISO8601.parse(literal);
+                if (c != null) {
+                    values.add(DateField.timeToString(c.getTimeInMillis()));
+                    log.debug("Coerced " + literal + " into DATE.");
                 }
             } else {
                 // long or double are possible at this point



Mime
View raw message