1- import { dialect , parse , testWc , test } from "./test_utils" ;
1+ import { dialect , parse , testWc , test , includeAll } from "./test_utils" ;
22
33describe ( "prepared statements" , ( ) => {
44 dialect ( [ "mysql" , "mariadb" ] , ( ) => {
@@ -8,6 +8,33 @@ describe("prepared statements", () => {
88 } ) ;
99 } ) ;
1010
11+ dialect ( [ "postgresql" ] , ( ) => {
12+ it ( "supports PREPARE .. AS statement" , ( ) => {
13+ testWc ( `PREPARE my_stmt AS SELECT * FROM my_table WHERE id = $1` , {
14+ paramTypes : [ "$nr" ] ,
15+ ...includeAll ,
16+ } ) ;
17+ testWc ( `PREPARE my_stmt AS UPDATE foo SET bar = $1` , { paramTypes : [ "$nr" ] , ...includeAll } ) ;
18+ testWc ( `PREPARE my_stmt AS DELETE FROM foo WHERE id = $1` , {
19+ paramTypes : [ "$nr" ] ,
20+ ...includeAll ,
21+ } ) ;
22+ testWc ( `PREPARE my_stmt AS INSERT INTO foo (bar) VALUES ($1)` , {
23+ paramTypes : [ "$nr" ] ,
24+ ...includeAll ,
25+ } ) ;
26+ testWc ( `PREPARE my_stmt AS MERGE INTO foo USING bar ON x = $1 WHEN MATCHED THEN DELETE` , {
27+ paramTypes : [ "$nr" ] ,
28+ ...includeAll ,
29+ } ) ;
30+ testWc ( `PREPARE my_stmt AS VALUES ($1), ($2), ($3)` , { paramTypes : [ "$nr" ] , ...includeAll } ) ;
31+ } ) ;
32+
33+ it ( "supports PREPARE .. AS with parameters" , ( ) => {
34+ testWc ( `PREPARE my_stmt(INT, TEXT) AS SELECT $1, $2` , { paramTypes : [ "$nr" ] , ...includeAll } ) ;
35+ } ) ;
36+ } ) ;
37+
1138 dialect ( [ "mysql" , "mariadb" , "postgresql" ] , ( ) => {
1239 it ( "supports EXECUTE" , ( ) => {
1340 testWc ( `EXECUTE my_stmt` ) ;
0 commit comments