48d7014067
FossilOrigin-Name: fba0b5fc7eead07a4853e78e02d788e7c714f6cd
85 lines
2.6 KiB
Plaintext
85 lines
2.6 KiB
Plaintext
# 2014 June 17
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#*************************************************************************
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix fts5ea
|
|
|
|
# If SQLITE_ENABLE_FTS5 is defined, omit this file.
|
|
ifcapable !fts5 {
|
|
finish_test
|
|
return
|
|
}
|
|
|
|
proc do_syntax_error_test {tn expr err} {
|
|
set ::se_expr $expr
|
|
do_catchsql_test $tn {SELECT fts5_expr($se_expr)} [list 1 $err]
|
|
}
|
|
|
|
proc do_syntax_test {tn expr res} {
|
|
set ::se_expr $expr
|
|
do_execsql_test $tn {SELECT fts5_expr($se_expr)} [list $res]
|
|
}
|
|
|
|
foreach {tn expr res} {
|
|
1 {abc} {"abc"}
|
|
2 {abc def} {"abc" AND "def"}
|
|
3 {abc*} {"abc" *}
|
|
4 {"abc def ghi" *} {"abc" + "def" + "ghi" *}
|
|
5 {one AND two} {"one" AND "two"}
|
|
6 {one+two} {"one" + "two"}
|
|
7 {one AND two OR three} {("one" AND "two") OR "three"}
|
|
8 {one OR two AND three} {"one" OR ("two" AND "three")}
|
|
9 {NEAR(one two)} {NEAR("one" "two", 10)}
|
|
10 {NEAR("one three"* two, 5)} {NEAR("one" + "three" * "two", 5)}
|
|
} {
|
|
do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res]
|
|
}
|
|
|
|
foreach {tn expr res} {
|
|
1 {c1:abc}
|
|
{c1 : "abc"}
|
|
2 {c2 : NEAR(one two) c1:"hello world"}
|
|
{c2 : NEAR("one" "two", 10) AND c1 : "hello" + "world"}
|
|
} {
|
|
do_execsql_test 2.$tn {SELECT fts5_expr($expr, 'c1', 'c2')} [list $res]
|
|
}
|
|
|
|
breakpoint
|
|
foreach {tn expr err} {
|
|
1 {AND} {fts5: syntax error near "AND"}
|
|
2 {abc def AND} {fts5: syntax error near ""}
|
|
3 {abc OR AND} {fts5: syntax error near "AND"}
|
|
4 {(a OR b) abc} {fts5: syntax error near "abc"}
|
|
5 {NEaR (a b)} {fts5: syntax error near "NEaR"}
|
|
6 {(a OR b) NOT c)} {fts5: syntax error near ")"}
|
|
7 {nosuch: a nosuch2: b} {no such column: nosuch}
|
|
8 {addr: a nosuch2: b} {no such column: nosuch2}
|
|
} {
|
|
do_catchsql_test 3.$tn {SELECT fts5_expr($expr, 'name', 'addr')} [list 1 $err]
|
|
}
|
|
|
|
|
|
|
|
# do_syntax_error_test 1.0 {NOT} {syntax error near "NOT"}
|
|
|
|
|
|
|
|
# do_catchsql_test 1.1 {
|
|
# SELECT fts5_expr('a OR b NOT c')
|
|
#} {0 {"a" OR "b" NOT "c"}}
|
|
|
|
|
|
#do_execsql_test 1.0 { SELECT fts5_expr('a') } {{"a"}}
|
|
|
|
finish_test
|