jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r577865 - in /jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query: AbstractOrderByTest.java AbstractQueryTest.java SQLOrderByTest.java SQLQueryLevel2Test.java
Date Thu, 20 Sep 2007 18:40:57 GMT
Author: jukka
Date: Thu Sep 20 11:40:55 2007
New Revision: 577865

URL: http://svn.apache.org/viewvc?rev=577865&view=rev
Log:
1.3: Merged revision 569490 (JCR-1083)

Modified:
    jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
    jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
    jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLOrderByTest.java
    jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLQueryLevel2Test.java

Modified: jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java?rev=577865&r1=577864&r2=577865&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
Thu Sep 20 11:40:55 2007
@@ -108,8 +108,8 @@
     protected void checkOrder(String[] nodeNames) throws RepositoryException {
         // first check ascending
 
-        String sql = "SELECT " + propertyName1 + " FROM " + testNodeType + " WHERE " +
-                    jcrPath + " LIKE '" + testRoot + "/%' ORDER BY " + propertyName1;
+        String sql = "SELECT " + escapeIdentifierForSQL(propertyName1) + " FROM " + escapeIdentifierForSQL(testNodeType)
+ " WHERE " +
+                    jcrPath + " LIKE '" + testRoot + "/%' ORDER BY " + escapeIdentifierForSQL(propertyName1);
         String xpath = "/" + jcrRoot + testRoot + "/*[@jcr:primaryType='" + testNodeType
+ "'] order by @" + propertyName1;
         Query q;
         QueryResult result;

Modified: jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java?rev=577865&r1=577864&r2=577865&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
Thu Sep 20 11:40:55 2007
@@ -305,4 +305,20 @@
         }
         return (Node[]) nodes.toArray(new Node[nodes.size()]);
     }
+    
+    /**
+     * Escape an identifier suitable for the SQL parser
+     * @TODO currently only handles dash character 
+     */
+    protected String escapeIdentifierForSQL(String identifier) {
+      
+        boolean needsEscaping = identifier.indexOf('-') >= 0;
+        
+        if (!needsEscaping) {
+            return identifier;
+        }
+        else {
+            return '"' + identifier + '"';
+        }
+    }
 }

Modified: jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLOrderByTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLOrderByTest.java?rev=577865&r1=577864&r2=577865&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLOrderByTest.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLOrderByTest.java
Thu Sep 20 11:40:55 2007
@@ -47,11 +47,11 @@
         isReadOnly = true;
         super.setUp();
         // setup common base statement
-        StringBuffer tmp = new StringBuffer("SELECT ").append(propertyName1);
-        tmp.append(" FROM ").append(testNodeType);
-        tmp.append(" WHERE ").append(propertyName1).append(" IS NOT NULL");
+        StringBuffer tmp = new StringBuffer("SELECT ").append(escapeIdentifierForSQL(propertyName1));
+        tmp.append(" FROM ").append(escapeIdentifierForSQL(testNodeType));
+        tmp.append(" WHERE ").append(escapeIdentifierForSQL(propertyName1)).append(" IS NOT
NULL");
         tmp.append(" ORDER BY ");
-        tmp.append(propertyName1);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
         baseStatement = tmp.toString();
     }
 

Modified: jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLQueryLevel2Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLQueryLevel2Test.java?rev=577865&r1=577864&r2=577865&view=diff
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLQueryLevel2Test.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLQueryLevel2Test.java
Thu Sep 20 11:40:55 2007
@@ -132,8 +132,8 @@
      */
     private Statement getFullTextStatement() {
         StringBuffer tmp = new StringBuffer("SELECT ");
-        tmp.append(propertyName1);
-        tmp.append(" FROM ").append(testNodeType);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
+        tmp.append(" FROM ").append(escapeIdentifierForSQL(testNodeType));
         tmp.append(" WHERE CONTAINS(., '''quick brown'' -cat')");
         tmp.append(" AND ").append(jcrPath).append(" LIKE '");
         tmp.append(testRoot).append("/%'");
@@ -146,12 +146,12 @@
      */
     private Statement getMultiValueStatement() {
         StringBuffer tmp = new StringBuffer("SELECT ");
-        tmp.append(propertyName1);
-        tmp.append(" FROM ").append(testNodeType);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
+        tmp.append(" FROM ").append(escapeIdentifierForSQL(testNodeType));
         tmp.append(" WHERE 'two' IN ");
-        tmp.append(propertyName2);
+        tmp.append(escapeIdentifierForSQL(propertyName2));
         tmp.append(" AND 'existence' IN ");
-        tmp.append(propertyName1);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
         tmp.append(" AND ").append(jcrPath).append(" LIKE '");
         tmp.append(testRoot).append("/%'");
         return new Statement(tmp.toString(), Query.SQL);
@@ -162,12 +162,12 @@
      */
     private Statement getRangeStatement() {
         StringBuffer tmp = new StringBuffer("SELECT ");
-        tmp.append(propertyName1);
-        tmp.append(" FROM ").append(testNodeType);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
+        tmp.append(" FROM ").append(escapeIdentifierForSQL(testNodeType));
         tmp.append(" WHERE ");
-        tmp.append(propertyName1);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
         tmp.append(" <= 'b' AND ");
-        tmp.append(propertyName1);
+        tmp.append(escapeIdentifierForSQL(propertyName1));
         tmp.append(" > 'a'");
         tmp.append(" AND ").append(jcrPath).append(" LIKE '");
         tmp.append(testRoot).append("/%'");



Mime
View raw message