@pgsql/transform 17.7.1 → 17.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/13/enums.d.ts +1 -1
- package/13/types.d.ts +1 -1
- package/14/enums.d.ts +1 -1
- package/14/types.d.ts +1 -1
- package/15/enums.d.ts +1 -1
- package/15/types.d.ts +1 -1
- package/16/enums.d.ts +1 -1
- package/16/types.d.ts +1 -1
- package/17/enums.d.ts +1 -1
- package/17/types.d.ts +1 -1
- package/README.md +105 -5
- package/esm/transformers/v14-to-v15.js +3 -0
- package/esm/transformers/v15-to-v16.js +60 -1
- package/package.json +4 -4
- package/transformers/v14-to-v15.js +3 -0
- package/transformers/v15-to-v16.d.ts +6 -0
- package/transformers/v15-to-v16.js +60 -1
- package/13/enum-to-int.d.ts +0 -7
- package/13/enum-to-int.js +0 -2165
- package/13/enum-to-str.d.ts +0 -7
- package/13/enum-to-str.js +0 -2165
- package/13/runtime-schema.d.ts +0 -17
- package/13/runtime-schema.js +0 -8419
- package/14/enum-to-int.d.ts +0 -7
- package/14/enum-to-int.js +0 -2205
- package/14/enum-to-str.d.ts +0 -7
- package/14/enum-to-str.js +0 -2205
- package/14/runtime-schema.d.ts +0 -17
- package/14/runtime-schema.js +0 -8695
- package/15/enum-to-int.d.ts +0 -7
- package/15/enum-to-int.js +0 -2255
- package/15/enum-to-str.d.ts +0 -7
- package/15/enum-to-str.js +0 -2255
- package/15/runtime-schema.d.ts +0 -17
- package/15/runtime-schema.js +0 -8955
- package/16/enum-to-int.d.ts +0 -7
- package/16/enum-to-int.js +0 -2344
- package/16/enum-to-str.d.ts +0 -7
- package/16/enum-to-str.js +0 -2344
- package/16/runtime-schema.d.ts +0 -17
- package/16/runtime-schema.js +0 -9339
- package/17/enum-to-int.d.ts +0 -7
- package/17/enum-to-int.js +0 -2501
- package/17/enum-to-str.d.ts +0 -7
- package/17/enum-to-str.js +0 -2501
- package/17/runtime-schema.d.ts +0 -17
- package/17/runtime-schema.js +0 -10010
- package/esm/13/enum-to-int.js +0 -2161
- package/esm/13/enum-to-str.js +0 -2161
- package/esm/13/runtime-schema.js +0 -8416
- package/esm/14/enum-to-int.js +0 -2201
- package/esm/14/enum-to-str.js +0 -2201
- package/esm/14/runtime-schema.js +0 -8692
- package/esm/15/enum-to-int.js +0 -2251
- package/esm/15/enum-to-str.js +0 -2251
- package/esm/15/runtime-schema.js +0 -8952
- package/esm/16/enum-to-int.js +0 -2340
- package/esm/16/enum-to-str.js +0 -2340
- package/esm/16/runtime-schema.js +0 -9336
- package/esm/17/enum-to-int.js +0 -2497
- package/esm/17/enum-to-str.js +0 -2497
- package/esm/17/runtime-schema.js +0 -10007
package/13/enums.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/13/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/14/enums.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/14/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/15/enums.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/15/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/16/enums.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/16/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/17/enums.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/17/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.
|
|
2
|
+
* This file was automatically generated by pg-proto-parser@1.29.2.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
4
|
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
5
|
*/
|
package/README.md
CHANGED
|
@@ -8,13 +8,112 @@
|
|
|
8
8
|
<a href="https://github.com/launchql/pgsql-parser/actions/workflows/run-tests.yaml">
|
|
9
9
|
<img height="20" src="https://github.com/launchql/pgsql-parser/actions/workflows/run-tests.yaml/badge.svg" />
|
|
10
10
|
</a>
|
|
11
|
-
<!-- <a href="https://www.npmjs.com/package/@pgsql/types"><img height="20" src="https://img.shields.io/npm/dt/@pgsql/types"></a> -->
|
|
12
|
-
<!-- <a href="https://www.npmjs.com/package/@pgsql/types"><img height="20" src="https://img.shields.io/npm/dw/@pgsql/types"/></a> -->
|
|
13
11
|
<a href="https://github.com/launchql/pgsql-parser/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
|
|
14
|
-
<a href="https://www.npmjs.com/package/@pgsql/
|
|
12
|
+
<a href="https://www.npmjs.com/package/@pgsql/transform"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/pgsql-parser?filename=packages%2Ftransform%2Fpackage.json"/></a>
|
|
15
13
|
</p>
|
|
16
14
|
|
|
17
|
-
`@pgsql/
|
|
15
|
+
`@pgsql/transform` is a TypeScript library for transforming PostgreSQL ASTs between different PostgreSQL versions. It serves as a crucial component for building a single source of truth deparser that can handle SQL from multiple PostgreSQL versions while maintaining backward compatibility.
|
|
16
|
+
|
|
17
|
+
## Transforming ASTs Between PG Versions
|
|
18
|
+
|
|
19
|
+
The transform package enables you to:
|
|
20
|
+
|
|
21
|
+
- **Transform legacy ASTs**: Convert ASTs from PostgreSQL versions 13-16 to version 17
|
|
22
|
+
- **Build unified deparsers**: Create a single deparser pipeline that works with multiple PostgreSQL versions
|
|
23
|
+
- **Maintain backward compatibility**: Support legacy codebases while leveraging the latest PostgreSQL features
|
|
24
|
+
|
|
25
|
+
## Key Limitation
|
|
26
|
+
|
|
27
|
+
This package only supports ASTs derived from SQL that is parseable by PostgreSQL 17. This means:
|
|
28
|
+
|
|
29
|
+
- ✅ **Supported**: SQL from PG13-16 that remains valid in PG17
|
|
30
|
+
- ❌ **Not supported**: Deprecated syntax from older versions that was removed
|
|
31
|
+
- ❌ **Not supported**: SQL that cannot be parsed by the PG17 parser
|
|
32
|
+
|
|
33
|
+
This design ensures all transformed ASTs can be reliably deparsed using the latest PostgreSQL grammar.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @pgsql/transform
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 🚀 Quick Start
|
|
42
|
+
|
|
43
|
+
### Multi-Version Transformer
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { ASTTransformer } from '@pgsql/transform';
|
|
47
|
+
|
|
48
|
+
const transformer = new ASTTransformer();
|
|
49
|
+
|
|
50
|
+
// Transform any version to PG17
|
|
51
|
+
const pg17Ast = transformer.transformToLatest(pg13Ast, 13);
|
|
52
|
+
|
|
53
|
+
// Transform between specific versions
|
|
54
|
+
const pg15Ast = transformer.transform(pg13Ast, 13, 15);
|
|
55
|
+
|
|
56
|
+
// Convenience methods
|
|
57
|
+
const result = transformer.transform13To17(pg13Ast);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Direct Transformers
|
|
61
|
+
|
|
62
|
+
For better performance when you know source and target versions:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { PG13ToPG17Transformer } from '@pgsql/transform';
|
|
66
|
+
|
|
67
|
+
const transformer = new PG13ToPG17Transformer();
|
|
68
|
+
const pg17Ast = transformer.transform(pg13Ast);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Integration Example
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { parse } from '@pgsql/parser';
|
|
75
|
+
import { deparse } from 'pgsql-deparser';
|
|
76
|
+
import { PG13ToPG17Transformer } from '@pgsql/transform';
|
|
77
|
+
|
|
78
|
+
// Parse with older version
|
|
79
|
+
const pg13Ast = await parse('SELECT * FROM users', { version: 13 });
|
|
80
|
+
|
|
81
|
+
// Transform to latest
|
|
82
|
+
const transformer = new PG13ToPG17Transformer();
|
|
83
|
+
const pg17Ast = transformer.transform(pg13Ast);
|
|
84
|
+
|
|
85
|
+
// Deparse with latest grammar
|
|
86
|
+
const sql = await deparse(pg17Ast);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 🔄 Transformation Chain
|
|
90
|
+
|
|
91
|
+
**Incremental**: PG13 → PG14 → PG15 → PG16 → PG17
|
|
92
|
+
- Step-by-step version upgrades
|
|
93
|
+
- Useful for debugging transformation issues
|
|
94
|
+
|
|
95
|
+
**Direct**: PG13 → PG17, PG14 → PG17, etc.
|
|
96
|
+
- Single-step transformations
|
|
97
|
+
- Optimized for performance
|
|
98
|
+
|
|
99
|
+
## 📋 Supported Transformations
|
|
100
|
+
|
|
101
|
+
| From | To | Transformer |
|
|
102
|
+
|------|----|-----------|
|
|
103
|
+
| PG13 | PG14, PG15, PG16, PG17 | `V13ToV14Transformer`, `PG13ToPG17Transformer` |
|
|
104
|
+
| PG14 | PG15, PG16, PG17 | `V14ToV15Transformer`, `PG14ToPG17Transformer` |
|
|
105
|
+
| PG15 | PG16, PG17 | `V15ToV16Transformer`, `PG15ToPG17Transformer` |
|
|
106
|
+
| PG16 | PG17 | `V16ToV17Transformer`, `PG16ToPG17Transformer` |
|
|
107
|
+
|
|
108
|
+
## 🏗️ Architecture
|
|
109
|
+
|
|
110
|
+
The transform package fits into the broader pgsql-parser ecosystem:
|
|
111
|
+
|
|
112
|
+
1. **Parse** legacy SQL with version-specific parsers
|
|
113
|
+
2. **Transform** ASTs to the latest version
|
|
114
|
+
3. **Deparse** using the unified, latest-version deparser
|
|
115
|
+
|
|
116
|
+
This enables a single source of truth for SQL generation while supporting legacy codebases.
|
|
18
117
|
|
|
19
118
|
## Related
|
|
20
119
|
|
|
@@ -24,6 +123,7 @@
|
|
|
24
123
|
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): Offers TypeScript type definitions for PostgreSQL AST nodes, facilitating type-safe construction, analysis, and manipulation of ASTs.
|
|
25
124
|
* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): Provides TypeScript enum definitions for PostgreSQL constants, enabling type-safe usage of PostgreSQL enums and constants in your applications.
|
|
26
125
|
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): A comprehensive utility library for PostgreSQL, offering type-safe AST node creation and enum value conversions, simplifying the construction and manipulation of PostgreSQL ASTs.
|
|
126
|
+
* [@pgsql/traverse](https://www.npmjs.com/package/@pgsql/traverse): PostgreSQL AST traversal utilities for pgsql-parser, providing a visitor pattern for traversing PostgreSQL Abstract Syntax Tree nodes, similar to Babel's traverse functionality but specifically designed for PostgreSQL AST structures.
|
|
27
127
|
* [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): A TypeScript tool that parses PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
|
|
28
128
|
* [libpg-query](https://github.com/launchql/libpg-query-node): The real PostgreSQL parser exposed for Node.js, used primarily in `pgsql-parser` for parsing and deparsing SQL queries.
|
|
29
129
|
|
|
@@ -31,4 +131,4 @@
|
|
|
31
131
|
|
|
32
132
|
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
33
133
|
|
|
34
|
-
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
|
134
|
+
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
|
@@ -654,6 +654,9 @@ export class V14ToV15Transformer {
|
|
|
654
654
|
if (node.name !== undefined) {
|
|
655
655
|
result.name = node.name;
|
|
656
656
|
}
|
|
657
|
+
if (node.num !== undefined) {
|
|
658
|
+
result.num = node.num;
|
|
659
|
+
}
|
|
657
660
|
if (node.newowner !== undefined) {
|
|
658
661
|
result.newowner = this.transform(node.newowner, context);
|
|
659
662
|
}
|
|
@@ -327,6 +327,18 @@ export class V15ToV16Transformer {
|
|
|
327
327
|
{ String: { sval: 'json_object' } }
|
|
328
328
|
];
|
|
329
329
|
}
|
|
330
|
+
else if (node.funcname.length === 2 &&
|
|
331
|
+
node.funcname[0]?.String?.sval === 'pg_catalog' &&
|
|
332
|
+
node.funcname[1]?.String?.sval === 'system_user' &&
|
|
333
|
+
node.funcformat === 'COERCE_SQL_SYNTAX') {
|
|
334
|
+
return {
|
|
335
|
+
ColumnRef: {
|
|
336
|
+
fields: [
|
|
337
|
+
{ String: { sval: 'system_user' } }
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
330
342
|
else {
|
|
331
343
|
result.funcname = Array.isArray(node.funcname)
|
|
332
344
|
? node.funcname.map((item) => this.transform(item, context))
|
|
@@ -432,6 +444,20 @@ export class V15ToV16Transformer {
|
|
|
432
444
|
return { A_Const: result };
|
|
433
445
|
}
|
|
434
446
|
ColumnRef(node, context) {
|
|
447
|
+
if (node.fields && Array.isArray(node.fields) && node.fields.length === 1) {
|
|
448
|
+
const field = node.fields[0];
|
|
449
|
+
if (field?.String?.sval === 'system_user') {
|
|
450
|
+
return {
|
|
451
|
+
FuncCall: {
|
|
452
|
+
funcname: [
|
|
453
|
+
{ String: { sval: 'pg_catalog' } },
|
|
454
|
+
{ String: { sval: 'system_user' } }
|
|
455
|
+
],
|
|
456
|
+
funcformat: 'COERCE_SQL_SYNTAX'
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
}
|
|
435
461
|
const result = {};
|
|
436
462
|
if (node.fields !== undefined) {
|
|
437
463
|
result.fields = Array.isArray(node.fields)
|
|
@@ -494,6 +520,30 @@ export class V15ToV16Transformer {
|
|
|
494
520
|
return { Alias: result };
|
|
495
521
|
}
|
|
496
522
|
RangeVar(node, context) {
|
|
523
|
+
if (node.relname === 'system_user' && node.inh === true && node.relpersistence === 'p') {
|
|
524
|
+
return {
|
|
525
|
+
RangeFunction: {
|
|
526
|
+
functions: [
|
|
527
|
+
{
|
|
528
|
+
List: {
|
|
529
|
+
items: [
|
|
530
|
+
{
|
|
531
|
+
FuncCall: {
|
|
532
|
+
funcname: [
|
|
533
|
+
{ String: { sval: 'pg_catalog' } },
|
|
534
|
+
{ String: { sval: 'system_user' } }
|
|
535
|
+
],
|
|
536
|
+
funcformat: 'COERCE_SQL_SYNTAX'
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
{}
|
|
540
|
+
]
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
497
547
|
const result = {};
|
|
498
548
|
if (node.catalogname !== undefined) {
|
|
499
549
|
result.catalogname = node.catalogname;
|
|
@@ -701,7 +751,13 @@ export class V15ToV16Transformer {
|
|
|
701
751
|
const result = {};
|
|
702
752
|
if (node.items !== undefined) {
|
|
703
753
|
result.items = Array.isArray(node.items)
|
|
704
|
-
? node.items.map((item) =>
|
|
754
|
+
? node.items.map((item) => {
|
|
755
|
+
const transformed = this.transform(item, context);
|
|
756
|
+
if (transformed === null) {
|
|
757
|
+
return {};
|
|
758
|
+
}
|
|
759
|
+
return transformed;
|
|
760
|
+
})
|
|
705
761
|
: this.transform(node.items, context);
|
|
706
762
|
}
|
|
707
763
|
return { List: result };
|
|
@@ -1628,6 +1684,9 @@ export class V15ToV16Transformer {
|
|
|
1628
1684
|
if (node.unique !== undefined) {
|
|
1629
1685
|
result.unique = node.unique;
|
|
1630
1686
|
}
|
|
1687
|
+
if (node.nulls_not_distinct !== undefined) {
|
|
1688
|
+
result.nulls_not_distinct = node.nulls_not_distinct;
|
|
1689
|
+
}
|
|
1631
1690
|
if (node.primary !== undefined) {
|
|
1632
1691
|
result.primary = node.primary;
|
|
1633
1692
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgsql/transform",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.8.0",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "Transform PostgreSQL AST types for pgsql-parser",
|
|
6
6
|
"main": "index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@pgsql/parser": "^1.1.4",
|
|
37
|
-
"pg-proto-parser": "^1.29.
|
|
38
|
-
"pgsql-deparser": "^17.
|
|
37
|
+
"pg-proto-parser": "^1.29.2",
|
|
38
|
+
"pgsql-deparser": "^17.9.0"
|
|
39
39
|
},
|
|
40
40
|
"keywords": [],
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "c2982c6793a8e92395a32e5d9d656b04e060466b"
|
|
42
42
|
}
|
|
@@ -657,6 +657,9 @@ class V14ToV15Transformer {
|
|
|
657
657
|
if (node.name !== undefined) {
|
|
658
658
|
result.name = node.name;
|
|
659
659
|
}
|
|
660
|
+
if (node.num !== undefined) {
|
|
661
|
+
result.num = node.num;
|
|
662
|
+
}
|
|
660
663
|
if (node.newowner !== undefined) {
|
|
661
664
|
result.newowner = this.transform(node.newowner, context);
|
|
662
665
|
}
|
|
@@ -40,6 +40,8 @@ export declare class V15ToV16Transformer {
|
|
|
40
40
|
};
|
|
41
41
|
FuncCall(node: PG15.FuncCall, context: TransformerContext): {
|
|
42
42
|
FuncCall: PG16.FuncCall;
|
|
43
|
+
} | {
|
|
44
|
+
ColumnRef: PG16.ColumnRef;
|
|
43
45
|
};
|
|
44
46
|
FuncExpr(node: PG15.FuncExpr, context: TransformerContext): {
|
|
45
47
|
FuncExpr: PG16.FuncExpr;
|
|
@@ -49,6 +51,8 @@ export declare class V15ToV16Transformer {
|
|
|
49
51
|
};
|
|
50
52
|
ColumnRef(node: PG15.ColumnRef, context: TransformerContext): {
|
|
51
53
|
ColumnRef: PG16.ColumnRef;
|
|
54
|
+
} | {
|
|
55
|
+
FuncCall: PG16.FuncCall;
|
|
52
56
|
};
|
|
53
57
|
TypeName(node: PG15.TypeName, context: TransformerContext): {
|
|
54
58
|
TypeName: PG16.TypeName;
|
|
@@ -58,6 +62,8 @@ export declare class V15ToV16Transformer {
|
|
|
58
62
|
};
|
|
59
63
|
RangeVar(node: PG15.RangeVar, context: TransformerContext): {
|
|
60
64
|
RangeVar: PG16.RangeVar;
|
|
65
|
+
} | {
|
|
66
|
+
RangeFunction: PG16.RangeFunction;
|
|
61
67
|
};
|
|
62
68
|
A_ArrayExpr(node: PG15.A_ArrayExpr, context: TransformerContext): {
|
|
63
69
|
A_ArrayExpr: PG16.A_ArrayExpr;
|
|
@@ -330,6 +330,18 @@ class V15ToV16Transformer {
|
|
|
330
330
|
{ String: { sval: 'json_object' } }
|
|
331
331
|
];
|
|
332
332
|
}
|
|
333
|
+
else if (node.funcname.length === 2 &&
|
|
334
|
+
node.funcname[0]?.String?.sval === 'pg_catalog' &&
|
|
335
|
+
node.funcname[1]?.String?.sval === 'system_user' &&
|
|
336
|
+
node.funcformat === 'COERCE_SQL_SYNTAX') {
|
|
337
|
+
return {
|
|
338
|
+
ColumnRef: {
|
|
339
|
+
fields: [
|
|
340
|
+
{ String: { sval: 'system_user' } }
|
|
341
|
+
]
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
333
345
|
else {
|
|
334
346
|
result.funcname = Array.isArray(node.funcname)
|
|
335
347
|
? node.funcname.map((item) => this.transform(item, context))
|
|
@@ -435,6 +447,20 @@ class V15ToV16Transformer {
|
|
|
435
447
|
return { A_Const: result };
|
|
436
448
|
}
|
|
437
449
|
ColumnRef(node, context) {
|
|
450
|
+
if (node.fields && Array.isArray(node.fields) && node.fields.length === 1) {
|
|
451
|
+
const field = node.fields[0];
|
|
452
|
+
if (field?.String?.sval === 'system_user') {
|
|
453
|
+
return {
|
|
454
|
+
FuncCall: {
|
|
455
|
+
funcname: [
|
|
456
|
+
{ String: { sval: 'pg_catalog' } },
|
|
457
|
+
{ String: { sval: 'system_user' } }
|
|
458
|
+
],
|
|
459
|
+
funcformat: 'COERCE_SQL_SYNTAX'
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}
|
|
438
464
|
const result = {};
|
|
439
465
|
if (node.fields !== undefined) {
|
|
440
466
|
result.fields = Array.isArray(node.fields)
|
|
@@ -497,6 +523,30 @@ class V15ToV16Transformer {
|
|
|
497
523
|
return { Alias: result };
|
|
498
524
|
}
|
|
499
525
|
RangeVar(node, context) {
|
|
526
|
+
if (node.relname === 'system_user' && node.inh === true && node.relpersistence === 'p') {
|
|
527
|
+
return {
|
|
528
|
+
RangeFunction: {
|
|
529
|
+
functions: [
|
|
530
|
+
{
|
|
531
|
+
List: {
|
|
532
|
+
items: [
|
|
533
|
+
{
|
|
534
|
+
FuncCall: {
|
|
535
|
+
funcname: [
|
|
536
|
+
{ String: { sval: 'pg_catalog' } },
|
|
537
|
+
{ String: { sval: 'system_user' } }
|
|
538
|
+
],
|
|
539
|
+
funcformat: 'COERCE_SQL_SYNTAX'
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
{}
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
}
|
|
500
550
|
const result = {};
|
|
501
551
|
if (node.catalogname !== undefined) {
|
|
502
552
|
result.catalogname = node.catalogname;
|
|
@@ -704,7 +754,13 @@ class V15ToV16Transformer {
|
|
|
704
754
|
const result = {};
|
|
705
755
|
if (node.items !== undefined) {
|
|
706
756
|
result.items = Array.isArray(node.items)
|
|
707
|
-
? node.items.map((item) =>
|
|
757
|
+
? node.items.map((item) => {
|
|
758
|
+
const transformed = this.transform(item, context);
|
|
759
|
+
if (transformed === null) {
|
|
760
|
+
return {};
|
|
761
|
+
}
|
|
762
|
+
return transformed;
|
|
763
|
+
})
|
|
708
764
|
: this.transform(node.items, context);
|
|
709
765
|
}
|
|
710
766
|
return { List: result };
|
|
@@ -1631,6 +1687,9 @@ class V15ToV16Transformer {
|
|
|
1631
1687
|
if (node.unique !== undefined) {
|
|
1632
1688
|
result.unique = node.unique;
|
|
1633
1689
|
}
|
|
1690
|
+
if (node.nulls_not_distinct !== undefined) {
|
|
1691
|
+
result.nulls_not_distinct = node.nulls_not_distinct;
|
|
1692
|
+
}
|
|
1634
1693
|
if (node.primary !== undefined) {
|
|
1635
1694
|
result.primary = node.primary;
|
|
1636
1695
|
}
|
package/13/enum-to-int.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by pg-proto-parser@1.29.1.
|
|
3
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source proto file,
|
|
4
|
-
* and run the pg-proto-parser generate command to regenerate this file.
|
|
5
|
-
*/
|
|
6
|
-
export type EnumType = "OverridingKind" | "QuerySource" | "SortByDir" | "SortByNulls" | "A_Expr_Kind" | "RoleSpecType" | "TableLikeOption" | "DefElemAction" | "PartitionRangeDatumKind" | "RTEKind" | "WCOKind" | "GroupingSetKind" | "CTEMaterialize" | "SetOperation" | "ObjectType" | "DropBehavior" | "AlterTableType" | "GrantTargetType" | "VariableSetKind" | "ConstrType" | "ImportForeignSchemaType" | "RoleStmtType" | "FetchDirection" | "FunctionParameterMode" | "TransactionStmtKind" | "ViewCheckOption" | "ClusterOption" | "DiscardMode" | "ReindexObjectType" | "AlterTSConfigType" | "AlterSubscriptionType" | "OnCommitAction" | "ParamKind" | "CoercionContext" | "CoercionForm" | "BoolExprType" | "SubLinkType" | "RowCompareType" | "MinMaxOp" | "SQLValueFunctionOp" | "XmlExprOp" | "XmlOptionType" | "NullTestType" | "BoolTestType" | "CmdType" | "JoinType" | "AggStrategy" | "AggSplit" | "SetOpCmd" | "SetOpStrategy" | "OnConflictAction" | "LimitOption" | "LockClauseStrength" | "LockWaitPolicy" | "LockTupleMode" | "KeywordKind" | "Token";
|
|
7
|
-
export declare const getEnumInt: (enumType: EnumType, key: string) => number;
|