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

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

E-mail: