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

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

E-mail: