7 let tt stmt scheme params
=
8 let print_scheme = RA.Scheme.to_string
in
9 let print_params = Stmt.params_to_string
in
12 Parser.parse_stmt stmt
14 | _
-> assert_failure
"parsing failed"
16 assert_equal ~printer
:print_scheme scheme s1
;
17 assert_equal ~printer
:print_params params p1
20 tt "CREATE TABLE test (id INT, str TEXT, name TEXT)"
23 tt "SELECT str FROM test WHERE id=?"
26 tt "SELECT x,y+? AS z FROM (SELECT id AS y,CONCAT(str,name) AS x FROM test WHERE id=@id*2) ORDER BY x,x+y LIMIT @lim"
27 [attr
"x" Text
; attr
"z" Int
]
28 [Next
,Some Int
; Named
"id", Some Int
; Named
"lim",Some Int
; ];
29 tt "select test.name,other.name from test, test as other where test.id=other.id + @delta"
30 [attr
"name" Text
; attr
"name" Text
]
31 [Named
"delta", Some Int
];
32 tt "select test.name from test where test.id = @x + ? or test.id = @x - ?"
34 [Named
"x", Some Int
; Next
, Some Int
; Named
"x", Some Int
; Next
, Some Int
;];
43 let test_suite = "main" >::: tests in
44 ignore
(run_test_tt
test_suite)