Skip to content

Commit f09a196

Browse files
committed
deparser in tests
1 parent c4d03dd commit f09a196

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

packages/utils/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ npm install @pgsql/utils
3939
With the AST helper methods, creating complex SQL ASTs becomes straightforward and intuitive.
4040

4141
```ts
42-
import { CreateStmt, ColumnDef } from '@pgsql/types';
42+
import { CreateStmt, ColumnDef } from '@pgsql/types/types/wrapped';
43+
import { deparse } from 'pgsql-deparser';
4344
import ast from '@pgsql/utils';
4445

4546
const newColumn: ColumnDef = ast.columnDef({
@@ -55,6 +56,8 @@ const createStmt: CreateStmt = ast.createStmt({
5556
}),
5657
tableElts: [newColumn]
5758
});
59+
60+
deparse(createStmt, {}) // SQL!
5861
```
5962

6063
### Enum Value Conversion

packages/utils/__test__/__snapshots__/utils.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`asts 1`] = `
4+
"CREATE TABLE (
5+
id int4
6+
) INHERITS ( )"
7+
`;
8+
39
exports[`getEnumValue 1`] = `"AEXPR_OP"`;
410

511
exports[`getEnumValue 2`] = `"AEXPR_OP_ANY"`;

packages/utils/__test__/utils.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as u from '../src';
22
import ast from '../src/asts';
3-
import { CreateStmt, ColumnDef } from '@pgsql/types';
3+
import { CreateStmt, ColumnDef } from '@pgsql/types/types/wrapped';
4+
import { deparse } from 'pgsql-deparser';
45

56
it('getEnumValue', () => {
67
expect(u.getEnumValue('A_Expr_Kind', 0)).toMatchSnapshot();
@@ -25,5 +26,5 @@ it('asts', () => {
2526
}),
2627
tableElts: [newColumn]
2728
})
28-
expect(createStmt).toBeTruthy();
29+
expect(deparse(createStmt, {})).toMatchSnapshot();
2930
});

packages/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"esprima": "4.0.1",
6767
"jest": "^29.5.0",
6868
"pg-proto-parser": "^1.12.2",
69+
"pgsql-deparser": "^13.11.0",
6970
"prettier": "^2.8.7",
7071
"rimraf": "5.0.5",
7172
"ts-jest": "^29.1.0",

0 commit comments

Comments
 (0)