You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2013/12/30 19:10:00 UTC
svn commit: r1554289 - in
/chemistry/opencmis/trunk/chemistry-opencmis-server:
chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/
chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmi...
Author: jens
Date: Mon Dec 30 18:09:59 2013
New Revision: 1554289
URL: http://svn.apache.org/r1554289
Log:
Query parser use double quotes for phrases, CMIS 1.1 change [CMIS-740]
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/TextSearch.g
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java?rev=1554289&r1=1554288&r2=1554289&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java Mon Dec 30 18:09:59 2013
@@ -946,7 +946,7 @@ public class EvalQueryTest extends Abstr
@Test
public void testContainsPhrase() {
log.debug("Start testContainsPhrase...");
- String statement = "SELECT * FROM " + COMPLEX_TYPE + " WHERE CONTAINS('\\'Kitty Katty\\'')";
+ String statement = "SELECT * FROM " + COMPLEX_TYPE + " WHERE CONTAINS('\"Kitty Katty\"')";
ObjectList res = doQuery(statement);
assertEquals(1, res.getObjects().size());
assertTrue(resultContains("beta", res));
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java?rev=1554289&r1=1554288&r2=1554289&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java Mon Dec 30 18:09:59 2013
@@ -599,7 +599,7 @@ public class ProcessQueryTest extends Ab
@Test
public void testOnTextPhraseLiteral() {
- String statement = "SELECT * FROM BookType WHERE CONTAINS('\\'abc\\'')";
+ String statement = "SELECT * FROM BookType WHERE CONTAINS('\"abc\"')";
testStatementMultiRule(statement, TestQueryProcessor.ON_TEXT_PHRASE);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java?rev=1554289&r1=1554288&r2=1554289&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java Mon Dec 30 18:09:59 2013
@@ -606,7 +606,7 @@ public class QueryParseTest extends Abst
@Test
public void whereTestContains2() {
- String statement = "SELECT p1 FROM MyType WHERE CONTAINS('Beethoven OR \\'Johann Sebastian\\' Mozart -Cage AND Orff')";
+ String statement = "SELECT p1 FROM MyType WHERE CONTAINS('Beethoven OR \"Johann Sebastian\" Mozart -Cage AND Orff')";
checkTreeWhere(statement);
Tree tree = findSearchExpression(statement);
printSearchTree(tree, statement);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/TextSearch.g
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/TextSearch.g?rev=1554289&r1=1554288&r2=1554289&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/TextSearch.g (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/TextSearch.g Mon Dec 30 18:09:59 2013
@@ -112,13 +112,16 @@ fragment
QUOTE: '\'';
fragment
+DOUBLE_QUOTE: '\"';
+
+fragment
BACKSL: '\\';
// An escape sequence is two backslashes for backslash, backslash single quote for single quote
// single quote single quote for single quote
fragment
ESC
- : BACKSL (QUOTE | BACKSL | TEXT_MINUS)
+ : BACKSL (QUOTE | DOUBLE_QUOTE | BACKSL | TEXT_MINUS | '*' | '?')
// add this line if you want to support double single quote as escaped quote for full text as in SQL-92
// | { ((CharStream)input).LT(2)=='\'' }? => QUOTE QUOTE
;
@@ -129,12 +132,12 @@ fragment
TEXT_SEARCH_PHRASE_STRING
:
( ESC
- | ~(BACKSL | QUOTE)
+ | ~(BACKSL | DOUBLE_QUOTE | TEXT_MINUS | QUOTE)
)+
;
TEXT_SEARCH_PHRASE_STRING_LIT
- : QUOTE TEXT_SEARCH_PHRASE_STRING QUOTE
+ : DOUBLE_QUOTE TEXT_SEARCH_PHRASE_STRING DOUBLE_QUOTE
;
// a literal for text search is a very generic rule and matches almost anything
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java?rev=1554289&r1=1554288&r2=1554289&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserTextSearch.java Mon Dec 30 18:09:59 2013
@@ -18,6 +18,8 @@
*/
package org.apache.chemistry.opencmis.server.support.query;
+import static org.junit.Assert.assertEquals;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -59,29 +61,30 @@ public class TestParserTextSearch extend
//
// <<
- // "ab c"
+ // ab c
// >> FAIL
@Test
public void testTEXT_SEARCH_WORD_LIT3() {
- testLexerFail("TEXT_SEARCH_WORD_LIT", "\"ab c\"");
+ testLexerFail("TEXT_SEARCH_WORD_LIT", "ab c");
}
//
// <<
- // "'abc'"
+ // 'abc'
// >> FAIL
@Test
public void testTEXT_SEARCH_WORD_LIT4() {
- testLexerFail("TEXT_SEARCH_WORD_LIT", "\"\'abc\'\"");
+ testLexerFail("TEXT_SEARCH_WORD_LIT", "\'abc\'");
}
//
// <<
- // "ab\'c"
+ // ab\'c
// >> OK
@Test
- public void testTEXT_SEARCH_WORD_LIT5() {
- testLexerOk("TEXT_SEARCH_WORD_LIT", "\"ab\\'c\"");
+ public void testWordLiteralWithSingleQuote() {
+ testLexerOk("TEXT_SEARCH_WORD_LIT", "ab\\'c");
+ testLexerFail("TEXT_SEARCH_WORD_LIT", "ab'c");
}
//
@@ -89,27 +92,11 @@ public class TestParserTextSearch extend
// "ab\\c"
// >> OK
@Test
- public void testTEXT_SEARCH_WORD_LIT6() {
- testLexerOk("TEXT_SEARCH_WORD_LIT", "\"ab\\\\c\"");
+ public void testPhraseWithBackslash() {
+ testLexerOk("TEXT_SEARCH_PHRASE_STRING_LIT", "\"ab\\\\c\"");
}
//
- // /*
- // <<
- // ab''c
- // >> OK
- // */
- /*
- * double quotes not supported in text search
- */
- /*
- @Test
- public void testTEXT_SEARCH_WORD_LIT7() {
- testLexerOk("TEXT_SEARCH_WORD_LIT", "ab''c");
- }
- */
-
- //
// phrase:
//
// <<
@@ -123,109 +110,129 @@ public class TestParserTextSearch extend
//
// <<
// "abc"
- // >> FAIL
+ // >> OK
@Test
public void testPhrase2() {
- testParserFail("phrase", "\"abc\"");
+ testParserOk("phrase", "\"abc\"");
}
//
// <<
- // 'abc'
+ // "'abc'"
// >> OK
@Test
public void testPhrase3() {
- testParserOk("phrase", "'abc'");
+ testParserFail("phrase", "'abc'");
+ testParserOk("phrase", "\"\\'abc\\'\"");
}
//
// <<
- // 'abc def'
+ // "abc def"
// >> OK
@Test
public void testPhrase4() {
- testParserOk("phrase", "'abc def'");
+ testParserOk("phrase", "\"abc def\"");
}
//
// <<
- // 'ab\-c'
+ // "ab\\c"
// >> OK
@Test
- public void testPhrase5() {
- testParserOk("phrase", "'ab\\-c'");
+ public void testPhrase6() {
+ testParserOk("phrase", "\"ab\\\\c\"");
}
//
// <<
- // 'ab\\c'
- // >> OK
+ // "ab\c"
+ // >> FAIL
@Test
- public void testPhrase6() {
- testParserOk("phrase", "'ab\\\\c'");
+ public void testPhraseEscapedBackslash() {
+ testParserFail("phrase", "\"ab\\c\"");
+ testParserOk("phrase", "\"ab\\\\c\"");
}
//
// <<
- // 'ab\c'
+ // "ab\\\c"
// >> FAIL
@Test
- public void testPhrase7() {
- testParserFail("phrase", "'ab\\c'");
+ public void testPhrase8() {
+ testParserFail("phrase", "\"ab\\\\\\c\"");
}
//
// <<
- // 'ab\\\c'
- // >> FAIL
+ // "ab\'c"
+ // >> OK
@Test
- public void testPhrase8() {
- testParserFail("phrase", "'ab\\\\\\c'");
+ public void testPhraseSingleQuote() {
+ assertEquals("ab'c", "ab\'c");
+ testParserOk("phrase", "\"ab\\'c\"");
+ testParserFail("phrase", "\"ab'c\""); //!!
}
//
// <<
- // 'ab\'c'
+ // "ab\-c"
// >> OK
@Test
- public void testPhrase9() {
- testParserOk("phrase", "'ab\\'c'");
+ public void testPhraseHyphen() {
+ testParserOk("phrase", "\"ab\\-c\"");
+ testParserFail("phrase", "\"ab-c\""); // !!!
}
//
+ // <<
+ // "abc*"
+ // "abc\*"
+ // "abc?"
+ // "abc\?"
+ // >> OK
+ @Test
+ public void testPhraseWildcards() {
+ testParserOk("phrase", "\"abc*\"");
+ testParserOk("phrase", "\"abc\\*\"");
+ testParserOk("phrase", "\"abc?\"");
+ testParserOk("phrase", "\"abc\\?\"");
+ }
+
+ //
// <<
- // 'abc def'
+ // "abc def"
// >> OK
@Test
public void testPhrase10() {
- testParserOk("phrase", "'abc def'");
+ testParserOk("phrase", "\"abc def\"");
}
//
// <<
- // '\'abc\''
+ // "\'abc\'"
// >> OK
@Test
public void testPhrase11() {
- testParserOk("phrase", "'\\'abc\\''");
+ testParserOk("phrase", "\"\\'abc\\'\"");
}
//
// <<
- // 'abc AND def'
+ // "abc AND def"
// >> OK
@Test
public void testPhrase12() {
- testParserOk("phrase", "'abc AND def'");
+ testParserOk("phrase", "\"abc AND def\"");
}
//
// <<
- // 'AND'
+ // "AND"
// >> OK
@Test
public void testPhrase13() {
- testParserOk("phrase", "'AND'");
+ testParserOk("phrase", "\"AND\"");
}
//
@@ -338,7 +345,7 @@ public class TestParserTextSearch extend
// >> OK
@Test
public void testWord13() {
- testParserOk("term", "'abc def'");
+ testParserOk("term", "\"abc def\"");
}
//
@@ -347,7 +354,7 @@ public class TestParserTextSearch extend
// >> OK
@Test
public void testWord14() {
- testParserOk("term", "-'abc def'");
+ testParserOk("term", "-\"abc def\"");
}
//
@@ -428,38 +435,38 @@ public class TestParserTextSearch extend
//
// <<
- // 'cat AND mouse'
+ // "cat AND mouse"
// >> OK
@Test
public void testTextSearchExpression6() {
- testParserOk("text_search_expression", "'cat AND mouse'");
+ testParserOk("text_search_expression", "\"cat AND mouse\"");
}
//
// <<
- // 'text search expression'
+ // "text search expression"
// >> OK
@Test
public void testTextSearchExpression7() {
- testParserOk("text_search_expression", "'text search expression'");
+ testParserOk("text_search_expression", "\"text search expression\"");
}
//
// <<
- // 'John\'s presentation'
+ // "John\'s presentation"
// >> OK
@Test
public void testTextSearchExpression8() {
- testParserOk("text_search_expression", "'John\\'s presentation'");
+ testParserOk("text_search_expression", "\"John\\'s presentation\"");
}
//
// <<
- // 'John\\'s presentation'
+ // "John\\'s presentation"
// >> FAIL
@Test
public void testTextSearchExpression9() {
- testParserFail("text_search_expression", "'John\\\\'s presentation'");
+ testParserFail("text_search_expression", "\"John\\\\'s presentation\"");
}
//
@@ -473,29 +480,29 @@ public class TestParserTextSearch extend
//
// <<
- // 'c:\\My Documents'
+ // "c:\\My Documents"
// >> OK
@Test
public void testTextSearchExpression11() {
- testParserOk("text_search_expression", "'c:\\\\My Documents'");
+ testParserOk("text_search_expression", "\"c:\\\\My Documents\"");
}
//
// <<
- // 'c:\\\My Documents'
+ // "c:\\\My Documents"
// >> FAIL
@Test
public void testTextSearchExpression13() {
- testParserFail("text_search_expression", "'c:\\\\\\My Documents'");
+ testParserFail("text_search_expression", "\"c:\\\\\\My Documents\"");
}
//
// <<
- // 'c:\My Documents'
+ // "c:\My Documents"
// >> FAIL
@Test
public void testTextSearchExpression14() {
- testParserFail("text_search_expression", "'c:\\My Documents'");
+ testParserFail("text_search_expression", "\"c:\\My Documents\"");
}
//