Annotation of parser3/tests/388-sql.html, revision 1.10

1.1       moko        1: @main[]
1.2       moko        2: 
                      3: $SQL[
1.8       moko        4:        $.drivers[^table::create{protocol       driver  client  connect
                      5: sqlite ../../sql/sqlite/.libs/libparser3sqlite.so      libsqlite3.so   sqlite://:memory:?multi_statements=1
                      6: mysql  ../../sql/mysql/.libs/libparser3mysql.so        libmariadbclient.so     mysql://@/?config_group=parser3&multi_statements=1
                      7: pgsql  ../../sql/pgsql/.libs/libparser3pgsql.so        libpq.so        pgsql://test@localhost/test
1.2       moko        8: }]
                      9: ]
                     10: 
1.10    ! moko       11: $ignore[^SQL.drivers.locate[protocol;sqlite]]
1.8       moko       12: 
                     13: ^connect[$SQL.drivers.connect]{
                     14: 
1.1       moko       15:        1. 2 + 2 = ^string:sql{select 2+2}
                     16: 
                     17:        2. void
                     18: 
1.7       moko       19:        2.0 $ignore[^try-catch{ ^void:sql{drop table pets} }]
                     20: 
1.5       moko       21:        2.1 ^void:sql{create table pets (pet varchar(128), food varchar(128), aggressive varchar(128), weigth varchar(128))}
1.1       moko       22: 
                     23:        2.2 ^void:sql{insert into pets values
                     24:                ('cat', 'milk', '^taint['very']', 5),
                     25:                ('dog', 'bone', '^taint["never"]', 10),
                     26:                ('parrot', 'grain', 'alwayws', 1)
                     27:           }
                     28: 
                     29:        2.3 ^try-catch{ ^void:sql{select * from pets} }
                     30:        2.4 ^try-catch{ ^void:sql{query}[ $.unknown[yes] ] }
                     31:        2.5 ^try-catch{ ^void:sql{query}[ $.bind[ $.name[value] ] ] }
                     32: 
1.7       moko       33:        2.6 Multiple queries: ^try-catch{ ^void:sql{delete from pets where pet='' ^; delete from pets where pet='' } }
                     34:        2.7 Exception in second query: ^try-catch{ ^void:sql{delete from pets where pet='' ^; select 2+2 } }
1.1       moko       35: 
                     36:        3. int/double
                     37: 
                     38:        3.1 $v(^int:sql{select 2}) $v $v.CLASS_NAME
                     39:        3.2 ^try-catch{ ^int:sql{select 2}[ $.limit(0) ] }
                     40:        3.3 ^int:sql{select 2}[ $.limit(0) $.default[1] ]
                     41: 
                     42:        3.4 $v(^double:sql{select -2}) $v $v.CLASS_NAME
                     43:        3.5 ^try-catch{ ^double:sql{select -2}[ $.limit(0) ] }
                     44:        3.6 ^double:sql{select -2}[ $.limit(0) $.default[1] ]
                     45: 
                     46: 
                     47:        4. hash
                     48: 
                     49:        4.1 ^h[select * from pets]
                     50: 
                     51:        4.2 ^h[select * from pets; $.type[table]]
                     52: 
                     53:        4.3 ^h[select pet, food from pets; $.type[string] ]
                     54: 
                     55:        4.4 ^try-catch{ ^h[select * from pets; $.type[string] ]}
                     56: 
                     57:        4.5. ^h[select * from pets; $.type[table] $.limit(1) $.offset(1) ]
                     58: 
1.6       moko       59:        4.6 ^try-catch{ ^h[select 'dup', pet from pets; $.type[string] ]}
                     60: 
1.1       moko       61: 
                     62:        5. table
                     63: 
                     64:        5.1 ^t[select * from pets]
                     65: 
                     66:        5.2. ^t[select * from pets; $.limit(1) $.offset(1) ]
                     67: 
1.4       moko       68:        5.3 ^try-catch{ ^t[select * from pets; $.bind[ $.name[value] ] ] }
                     69: 
                     70:        5.4 ^try-catch{ ^t[select * from pets; $.no-such-option[] ] }
                     71: 
1.1       moko       72: 
                     73:        6. file
                     74: 
                     75:        6.1 ^f[select aggressive,'test.txt' from pets; $.limit(1) $.content-type[text/plain] ]
                     76: 
                     77:        6.2 ^f[select aggressive,'test.txt','unknown' from pets; $.limit(1) $.name[unknown] $.offset(1) ]
                     78: 
                     79:        6.3 ^try-catch{ ^f[select * from pets; $.limit(1) ] }
                     80: 
                     81:        6.4 ^try-catch{ ^f[select aggressive from pets; $.limit(0) ] }
                     82: 
                     83:        6.5 ^try-catch{ ^f[select 1 from pets] } - bug!
                     84: 
                     85:        6.6 ^try-catch{ ^f[select 1,2 from pets] }
                     86: 
                     87:        6.7 ^try-catch{ ^f[select aggressive from pets; $.unknown[yes] ] }
                     88: 
                     89:        6.8 $f[^file::create["'test'"]] ^f.sql-string[]
                     90: 
1.3       moko       91:        7. string
                     92: 
                     93:        7.1 ^try-catch{ ^s[select * from pets; $.limit(1) $.offset(1) ] }
                     94:        7.2 ^try-catch{ ^s[select pet from pets] }
                     95:        7.3 ^try-catch{ ^s[select 2+2; $.bind[ $.name[$value] ] ] }
                     96:        7.4 ^try-catch{ ^s[select 2+2; $.no-such-option[] ] }
                     97:        7.5 ^try-catch{ ^s[select pet from pets; $.limit(0) ] }
                     98:        7.6 ^s[select pet from pets; $.limit(0) $.default{default} ]
1.1       moko       99: 
                    100: }
                    101: 
                    102: @h[query;options]
                    103:        $h[^hash::sql{$query}[$options]]
                    104:        ^json:string[$h; $.indent(1) ]
                    105: 
                    106: @t[query;options]
                    107:        $t[^table::sql{$query}[$options]]
                    108:        ^json:string[$t; $.indent(1) ]
                    109: 
                    110: @f[query;options]
                    111:        $f[^file::sql{$query}[$options]]
                    112:        ^json:string[$f; $.indent(1) $.file[text] ]
1.3       moko      113: 
                    114: @s[query;options]
                    115:        $s[^string:sql{$query}[$options]]
                    116:        "$s"

E-mail: