--- parser3/tests/388-sql.html 2017/12/06 01:51:25 1.1 +++ parser3/tests/388-sql.html 2019/10/24 11:28:48 1.7 @@ -1,11 +1,22 @@ @main[] -^connect[sqlite://:memory:]{ + +$SQL[ + $.drivers[^table::create{protocol driver client +sqlite ../../sql/sqlite/.libs/libparser3sqlite.so libsqlite3.so +mysql ../../sql/mysql/.libs/libparser3mysql.so libmariadbclient.so +}] +] + +#config_group +^connect[^if(0){sqlite://:memory:?}{mysql://@/?config_group=parser3&}multi_statements=1]{ 1. 2 + 2 = ^string:sql{select 2+2} 2. void - 2.1 ^void:sql{create table pets (pet varchar, food varchar, aggressive varchar, weigth varchar)} + 2.0 $ignore[^try-catch{ ^void:sql{drop table pets} }] + + 2.1 ^void:sql{create table pets (pet varchar(128), food varchar(128), aggressive varchar(128), weigth varchar(128))} 2.2 ^void:sql{insert into pets values ('cat', 'milk', '^taint['very']', 5), @@ -17,6 +28,8 @@ 2.4 ^try-catch{ ^void:sql{query}[ $.unknown[yes] ] } 2.5 ^try-catch{ ^void:sql{query}[ $.bind[ $.name[value] ] ] } + 2.6 Multiple queries: ^try-catch{ ^void:sql{delete from pets where pet='' ^; delete from pets where pet='' } } + 2.7 Exception in second query: ^try-catch{ ^void:sql{delete from pets where pet='' ^; select 2+2 } } 3. int/double @@ -41,6 +54,8 @@ 4.5. ^h[select * from pets; $.type[table] $.limit(1) $.offset(1) ] + 4.6 ^try-catch{ ^h[select 'dup', pet from pets; $.type[string] ]} + 5. table @@ -48,6 +63,10 @@ 5.2. ^t[select * from pets; $.limit(1) $.offset(1) ] + 5.3 ^try-catch{ ^t[select * from pets; $.bind[ $.name[value] ] ] } + + 5.4 ^try-catch{ ^t[select * from pets; $.no-such-option[] ] } + 6. file @@ -67,6 +86,14 @@ 6.8 $f[^file::create["'test'"]] ^f.sql-string[] + 7. string + + 7.1 ^try-catch{ ^s[select * from pets; $.limit(1) $.offset(1) ] } + 7.2 ^try-catch{ ^s[select pet from pets] } + 7.3 ^try-catch{ ^s[select 2+2; $.bind[ $.name[$value] ] ] } + 7.4 ^try-catch{ ^s[select 2+2; $.no-such-option[] ] } + 7.5 ^try-catch{ ^s[select pet from pets; $.limit(0) ] } + 7.6 ^s[select pet from pets; $.limit(0) $.default{default} ] } @@ -81,3 +108,7 @@ @f[query;options] $f[^file::sql{$query}[$options]] ^json:string[$f; $.indent(1) $.file[text] ] + +@s[query;options] + $s[^string:sql{$query}[$options]] + "$s"