@@ -61,7 +61,7 @@ Explore the PostgreSQL Abstract Syntax Tree (AST) as JSON objects with ease usin
6161``` ts
6262import * as t from ' @pgsql/utils' ;
6363import { SelectStmt } from ' @pgsql/types' ;
64- import { deparseSync as deparse } from ' pgsql-deparser' ;
64+ import { deparse } from ' pgsql-deparser' ;
6565
6666const selectStmt: { SelectStmt: SelectStmt } = t .nodes .selectStmt ({
6767 targetList: [
@@ -83,16 +83,16 @@ const selectStmt: { SelectStmt: SelectStmt } = t.nodes.selectStmt({
8383});
8484console .log (selectStmt );
8585// Output: { "SelectStmt": { "targetList": [ { "ResTarget": { "val": { "ColumnRef": { "fields": [ { "A_Star": {} } ] } } } } ], "fromClause": [ { "RangeVar": { "relname": "some_amazing_table", "inh": true, "relpersistence": "p" } } ], "limitOption": "LIMIT_OPTION_DEFAULT", "op": "SETOP_NONE" } }
86- console .log (deparse (stmt ))
86+ console .log (await deparse (stmt ))
8787// Output: SELECT * FROM some_amazing_table
8888```
8989
9090#### Select Statement
9191
9292``` ts
9393import * as t from ' @pgsql/utils' ;
94- import { RangeVar , SelectStmt } from ' @pgsql/types' ;
95- import { deparseSync as deparse } from ' pgsql-deparser' ;
94+ import { SelectStmt } from ' @pgsql/types' ;
95+ import { deparse } from ' pgsql-deparser' ;
9696
9797const query: { SelectStmt: SelectStmt } = t .nodes .selectStmt ({
9898 targetList: [
@@ -128,7 +128,7 @@ const query: { SelectStmt: SelectStmt } = t.nodes.selectStmt({
128128 op: ' SETOP_NONE'
129129});
130130
131- deparse (createStmt , {} );
131+ await deparse (createStmt );
132132// SELECT name, email FROM users WHERE age > 18
133133```
134134
@@ -167,7 +167,7 @@ const createStmt = t.nodes.createStmt({
167167});
168168
169169// `deparse` function converts AST to SQL string
170- const sql = deparse (createStmt );
170+ const sql = await deparse (createStmt , { pretty: true } );
171171
172172console .log (sql );
173173// OUTPUT:
0 commit comments