chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r901294 - in /incubator/chemistry/trunk/chemistry/chemistry-commons/src: main/antlr3/org/apache/chemistry/cmissql/ main/antlr3/org/apache/chemistry/impl/simple/ main/java/org/apache/chemistry/impl/simple/ test/gunit/org/apache/chemistry/cmi...
Date Wed, 20 Jan 2010 17:32:51 GMT
Author: fguillaume
Date: Wed Jan 20 17:32:50 2010
New Revision: 901294

URL: http://svn.apache.org/viewvc?rev=901294&view=rev
Log:
Make query keywords case-insensitive

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlLexer.g
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlParser.g
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/impl/simple/CmisSqlSimpleWalker.g
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/gunit/org/apache/chemistry/cmissql/CmisSql.testsuite
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlLexer.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlLexer.g?rev=901294&r1=901293&r2=901294&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlLexer.g
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlLexer.g
Wed Jan 20 17:32:50 2010
@@ -62,34 +62,34 @@
 
 // ----- Generic SQL -----
 
-SELECT : 'SELECT';
-FROM : 'FROM';
-AS : 'AS';
-JOIN : 'JOIN';
-INNER : 'INNER';
-OUTER : 'OUTER';
-LEFT : 'LEFT';
-RIGHT : 'RIGHT';
-ON : 'ON';
-WHERE : 'WHERE';
-ORDER : 'ORDER';
-BY : 'BY';
-ASC : 'ASC';
-DESC : 'DESC';
+SELECT : ('S'|'s')('E'|'e')('L'|'l')('E'|'e')('C'|'c')('T'|'t');
+FROM : ('F'|'f')('R'|'r')('O'|'o')('M'|'m');
+AS : ('A'|'a')('S'|'s');
+JOIN : ('J'|'j')('O'|'o')('I'|'i')('N'|'n');
+INNER : ('I'|'i')('N'|'n')('N'|'n')('E'|'e')('R'|'r');
+OUTER : ('O'|'o')('U'|'u')('T'|'t')('E'|'e')('R'|'r');
+LEFT : ('L'|'l')('E'|'e')('F'|'f')('T'|'t');
+RIGHT : ('R'|'r')('I'|'i')('G'|'g')('H'|'h')('T'|'t');
+ON : ('O'|'o')('N'|'n');
+WHERE : ('W'|'w')('H'|'h')('E'|'e')('R'|'r')('E'|'e');
+ORDER : ('O'|'o')('R'|'r')('D'|'d')('E'|'e')('R'|'r');
+BY : ('B'|'b')('Y'|'y');
+ASC : ('A'|'a')('S'|'s')('C'|'c');
+DESC : ('D'|'d')('E'|'e')('S'|'s')('C'|'c');
 
 // ----- Operators -----
-IS : 'IS';
-NULL : 'NULL';
-AND : 'AND';
-OR : 'OR';
-NOT : 'NOT';
-IN : 'IN';
-LIKE : 'LIKE';
-ANY : 'ANY';
-CONTAINS : 'CONTAINS';
-SCORE : 'SCORE';
-IN_FOLDER : 'IN_FOLDER';
-IN_TREE : 'IN_TREE';
+IS : ('I'|'i')('S'|'s');
+NULL : ('N'|'n')('U'|'u')('L'|'l')('L'|'l');
+AND : ('A'|'a')('N'|'n')('D'|'d');
+OR : ('O'|'o')('R'|'r');
+NOT : ('N'|'n')('O'|'o')('T'|'t');
+IN : ('I'|'i')('N'|'n');
+LIKE : ('L'|'l')('I'|'i')('K'|'k')('E'|'e');
+ANY : ('A'|'a')('N'|'n')('Y'|'y');
+CONTAINS : ('C'|'c')('O'|'o')('N'|'n')('T'|'t')('A'|'a')('I'|'i')('N'|'n')('S'|'s');
+SCORE : ('S'|'s')('C'|'c')('O'|'o')('R'|'r')('E'|'e');
+IN_FOLDER : ('I'|'i')('N'|'n')'_'('F'|'f')('O'|'o')('L'|'l')('D'|'d')('E'|'e')('R'|'r');
+IN_TREE : ('I'|'i')('N'|'n')'_'('T'|'t')('R'|'r')('E'|'e')('E'|'e');
 
 STAR : '*';
 LPAR : '(';

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlParser.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlParser.g?rev=901294&r1=901293&r2=901294&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlParser.g
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/cmissql/CmisSqlParser.g
Wed Jan 20 17:32:50 2010
@@ -50,6 +50,20 @@
 package org.apache.chemistry.cmissql;
 }
 
+@members {
+    public String errorMessage;
+
+    @Override
+    public void displayRecognitionError(String[] tokenNames,
+            RecognitionException e) {
+        if (errorMessage == null) {
+            String hdr = getErrorHeader(e);
+            String msg = getErrorMessage(e, tokenNames);
+            errorMessage = hdr + " " + msg;
+        }
+    }
+}
+
 query: SELECT^ select_list from_clause where_clause? order_by_clause?;
 
 select_list

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/impl/simple/CmisSqlSimpleWalker.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/impl/simple/CmisSqlSimpleWalker.g?rev=901294&r1=901293&r2=901294&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/impl/simple/CmisSqlSimpleWalker.g
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/antlr3/org/apache/chemistry/impl/simple/CmisSqlSimpleWalker.g
Wed Jan 20 17:32:50 2010
@@ -53,6 +53,7 @@
 
 @members {
     public SimpleData data;
+
     public SimpleConnection connection;
 
     public String errorMessage;
@@ -61,7 +62,9 @@
     public void displayRecognitionError(String[] tokenNames,
             RecognitionException e) {
         if (errorMessage == null) {
-            errorMessage = getErrorMessage(e, tokenNames);
+            String hdr = getErrorHeader(e);
+            String msg = getErrorMessage(e, tokenNames);
+            errorMessage = hdr + " " + msg;
         }
     }
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=901294&r1=901293&r2=901294&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
Wed Jan 20 17:32:50 2010
@@ -69,7 +69,6 @@
 import org.apache.chemistry.VersioningState;
 import org.apache.chemistry.cmissql.CmisSqlLexer;
 import org.apache.chemistry.cmissql.CmisSqlParser;
-import org.apache.chemistry.impl.simple.CmisSqlSimpleWalker.query_return;
 import org.apache.chemistry.util.GregorianCalendar;
 
 public class SimpleConnection implements Connection, SPI {
@@ -782,11 +781,17 @@
                     statement.getBytes("UTF-8")));
             TokenSource lexer = new CmisSqlLexer(input);
             TokenStream tokens = new CommonTokenStream(lexer);
-            CommonTree tree = (CommonTree) new CmisSqlParser(tokens).query().getTree();
+            CmisSqlParser parser = new CmisSqlParser(tokens);
+            CmisSqlParser.query_return query = parser.query();
+            if (parser.errorMessage != null) {
+                throw new CMISRuntimeException("Cannot parse query: "
+                        + statement + " (" + parser.errorMessage + ")");
+            }
+            CommonTree tree = (CommonTree) query.getTree();
             CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
             nodes.setTokenStream(tokens);
             CmisSqlSimpleWalker walker = new CmisSqlSimpleWalker(nodes);
-            query_return res = walker.query(data, this);
+            CmisSqlSimpleWalker.query_return res = walker.query(data, this);
             if (walker.errorMessage != null) {
                 throw new CMISRuntimeException("Cannot parse query: "
                         + statement + " (" + walker.errorMessage + ")");

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/gunit/org/apache/chemistry/cmissql/CmisSql.testsuite
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/gunit/org/apache/chemistry/cmissql/CmisSql.testsuite?rev=901294&r1=901293&r2=901294&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/gunit/org/apache/chemistry/cmissql/CmisSql.testsuite
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/gunit/org/apache/chemistry/cmissql/CmisSql.testsuite
Wed Jan 20 17:32:50 2010
@@ -59,7 +59,7 @@
 "-123" OK
 "0" OK
 "0123" FAIL
-"abc123" FAIL
+"abc123" OK
 "123abc" FAIL
 "'abc'" OK
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java?rev=901294&r1=901293&r2=901294&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
Wed Jan 20 17:32:50 2010
@@ -270,6 +270,9 @@
         Collection<CMISObject> res = conn.query("SELECT * FROM cmis:folder",
                 false);
         assertEquals(1, res.size()); // the root
+        // case insensitive on keywords and types
+        res = conn.query("seLect * fRoM cmis:Folder", false);
+        assertEquals(1, res.size());
         res = conn.query("SELECT * FROM fold", false);
         assertEquals(0, res.size());
         res = conn.query("SELECT * FROM doc", false);



Mime
View raw message