3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #*************************************************************************
13 source [file join [file dirname [info script]] fts5_common.tcl]
16 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
22 proc do_syntax_error_test {tn expr err} {
24 do_catchsql_test $tn {SELECT fts5_expr($se_expr)} [list 1 $err]
27 proc do_syntax_test {tn expr res} {
29 do_execsql_test $tn {SELECT fts5_expr($se_expr)} [list $res]
32 foreach {tn expr res} {
36 4 {abc OR ""} {"abc" OR ""}
37 5 {abc NOT ""} {"abc" NOT ""}
38 6 {abc AND ""} {"abc" AND ""}
39 7 {"" OR abc} {"" OR "abc"}
40 8 {"" NOT abc} {"" NOT "abc"}
41 9 {"" AND abc} {"" AND "abc"}
42 10 {abc + "" + def} {"abc" + "def"}
43 11 {abc "" def} {"abc" AND "def"}
44 12 {r+e OR w} {"r" + "e" OR "w"}
46 13 {a AND b NOT c} {"a" AND ("b" NOT "c")}
47 14 {a OR b NOT c} {"a" OR ("b" NOT "c")}
48 15 {a NOT b AND c} {("a" NOT "b") AND "c"}
49 16 {a NOT b OR c} {("a" NOT "b") OR "c"}
51 17 {a AND b OR c} {("a" AND "b") OR "c"}
52 18 {a OR b AND c} {"a" OR ("b" AND "c")}
55 do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res]
58 do_catchsql_test 2.1 {
60 } {1 {wrong number of arguments to function fts5_expr}}
62 do_catchsql_test 2.2 {
63 SELECT fts5_expr_tcl()
64 } {1 {wrong number of arguments to function fts5_expr_tcl}}
66 do_catchsql_test 2.3 {
68 } {1 {fts5: syntax error near ""}}
70 do_catchsql_test 2.4 {
71 SELECT fts5_expr(NULL)
72 } {1 {fts5: syntax error near ""}}
74 do_catchsql_test 2.5 {
75 SELECT fts5_expr(NULL, NULL)
76 } {1 {parse error in ""}}
78 for {set i 0} {$i < 255} {incr i} {
80 lindex [catchsql {sELECT fts5_expr(NULL, char($i));}] 0
85 CREATE VIRTUAL TABLE e1 USING fts5(text, tokenize = 'porter unicode61');
86 INSERT INTO e1 VALUES ('just a few words with a / inside');
89 SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '"just"' ORDER BY rank;
92 SELECT rowid FROM e1 WHERE e1 MATCH '"/" OR "just"'
95 SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '"/" OR "just"' ORDER BY rank;
99 SELECT fts5_expr_tcl('e AND \" \"');
100 " {{AND [nearset -- {e}] [{}]}}