pgsql-deparser 17.18.5 → 17.19.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.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Auto-generated file with types stripped for better tree-shaking
3
+ * DO NOT EDIT - Generated by strip-transformer-types.ts
4
+ */
5
+ /**
6
+ * V17 to V18 AST Transformer
7
+ * Transforms PostgreSQL v17 AST nodes to v18 format
8
+ *
9
+ * Structural changes in v18:
10
+ * - InsertStmt/UpdateStmt/DeleteStmt/MergeStmt: returningList -> returningClause { exprs }
11
+ * - Constraint: new is_enforced flag (true by default for CHECK/FOREIGN/NOTNULL)
12
+ * - Constraint: CONSTR_GENERATED gains generated_kind ('s' = STORED, 'v' = VIRTUAL)
13
+ * - Column-level NOT NULL constraints gain initially_valid: true
14
+ */
15
+ export declare class V17ToV18Transformer {
16
+ transform(node: any, context?: any): any;
17
+ visit(node: any, context?: any): any;
18
+ /**
19
+ * Generic recursive walk that re-dispatches wrapped nodes with a
20
+ * dedicated transformer method and deep-copies everything else.
21
+ */
22
+ private walkValue;
23
+ getNodeType(node: any): any;
24
+ getNodeData(node: any): any;
25
+ ParseResult(node: any, context: any): any;
26
+ RawStmt(node: any, context: any): {
27
+ RawStmt: any;
28
+ };
29
+ /**
30
+ * Convert a v17 returningList into a v18 ReturningClause
31
+ */
32
+ private transformReturningList;
33
+ private transformDmlStatement;
34
+ InsertStmt(node: any, context: any): {
35
+ InsertStmt: any;
36
+ };
37
+ UpdateStmt(node: any, context: any): {
38
+ UpdateStmt: any;
39
+ };
40
+ DeleteStmt(node: any, context: any): {
41
+ DeleteStmt: any;
42
+ };
43
+ MergeStmt(node: any, context: any): {
44
+ MergeStmt: any;
45
+ };
46
+ AlterTableCmd(node: any, context: any): {
47
+ AlterTableCmd: any;
48
+ };
49
+ VariableSetStmt(node: any, context: any): {
50
+ VariableSetStmt: any;
51
+ };
52
+ Constraint(node: any, context: any): {
53
+ Constraint: any;
54
+ };
55
+ }
package/v17-to-v18.js ADDED
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ /**
3
+ * Auto-generated file with types stripped for better tree-shaking
4
+ * DO NOT EDIT - Generated by strip-transformer-types.ts
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.V17ToV18Transformer = void 0;
8
+ // @ts-nocheck
9
+ /**
10
+ * V17 to V18 AST Transformer
11
+ * Transforms PostgreSQL v17 AST nodes to v18 format
12
+ *
13
+ * Structural changes in v18:
14
+ * - InsertStmt/UpdateStmt/DeleteStmt/MergeStmt: returningList -> returningClause { exprs }
15
+ * - Constraint: new is_enforced flag (true by default for CHECK/FOREIGN/NOTNULL)
16
+ * - Constraint: CONSTR_GENERATED gains generated_kind ('s' = STORED, 'v' = VIRTUAL)
17
+ * - Column-level NOT NULL constraints gain initially_valid: true
18
+ */
19
+ class V17ToV18Transformer {
20
+ transform(node, context = { parentNodeTypes: [] }) {
21
+ if (node == null) {
22
+ return null;
23
+ }
24
+ if (typeof node === 'number' || node instanceof Number) {
25
+ return node;
26
+ }
27
+ if (typeof node === 'string') {
28
+ return node;
29
+ }
30
+ try {
31
+ return this.visit(node, context);
32
+ }
33
+ catch (error) {
34
+ const nodeType = Object.keys(node)[0];
35
+ throw new Error(`Error transforming ${nodeType}: ${error.message}`);
36
+ }
37
+ }
38
+ visit(node, context = { parentNodeTypes: [] }) {
39
+ if (node && typeof node === 'object' && 'version' in node && 'stmts' in node) {
40
+ return this.ParseResult(node, context);
41
+ }
42
+ const nodeType = this.getNodeType(node);
43
+ // Handle empty objects
44
+ if (!nodeType) {
45
+ return {};
46
+ }
47
+ const nodeData = this.getNodeData(node);
48
+ const methodName = nodeType;
49
+ if (typeof this[methodName] === 'function') {
50
+ const childContext = {
51
+ ...context,
52
+ parentNodeTypes: [...context.parentNodeTypes, nodeType]
53
+ };
54
+ const result = this[methodName](nodeData, childContext);
55
+ return result;
56
+ }
57
+ // No specific method: recurse into children so nested statements
58
+ // (e.g. DML inside CTEs) still get transformed
59
+ return this.walkValue(node, context);
60
+ }
61
+ /**
62
+ * Generic recursive walk that re-dispatches wrapped nodes with a
63
+ * dedicated transformer method and deep-copies everything else.
64
+ */
65
+ walkValue(value, context) {
66
+ if (value == null || typeof value !== 'object') {
67
+ return value;
68
+ }
69
+ if (Array.isArray(value)) {
70
+ return value.map(item => this.walkValue(item, context));
71
+ }
72
+ const keys = Object.keys(value);
73
+ if (keys.length === 1 && typeof this[keys[0]] === 'function') {
74
+ // Wrapped node with a dedicated transformer method
75
+ return this.visit(value, context);
76
+ }
77
+ const result = {};
78
+ for (const key of keys) {
79
+ result[key] = this.walkValue(value[key], context);
80
+ }
81
+ return result;
82
+ }
83
+ getNodeType(node) {
84
+ return Object.keys(node)[0];
85
+ }
86
+ getNodeData(node) {
87
+ const keys = Object.keys(node);
88
+ if (keys.length === 1 && typeof node[keys[0]] === 'object') {
89
+ return node[keys[0]];
90
+ }
91
+ return node;
92
+ }
93
+ ParseResult(node, context) {
94
+ if (node && typeof node === 'object' && 'version' in node && 'stmts' in node) {
95
+ return {
96
+ version: 180004, // PG18 version
97
+ stmts: node.stmts.map((stmt) => {
98
+ if (stmt && typeof stmt === 'object' && 'stmt' in stmt) {
99
+ return {
100
+ ...stmt,
101
+ stmt: this.transform(stmt.stmt, context)
102
+ };
103
+ }
104
+ return this.transform(stmt, context);
105
+ })
106
+ };
107
+ }
108
+ return node;
109
+ }
110
+ RawStmt(node, context) {
111
+ const result = {};
112
+ if (node.stmt !== undefined) {
113
+ result.stmt = this.transform(node.stmt, context);
114
+ }
115
+ if (node.stmt_location !== undefined) {
116
+ result.stmt_location = node.stmt_location;
117
+ }
118
+ if (node.stmt_len !== undefined) {
119
+ result.stmt_len = node.stmt_len;
120
+ }
121
+ return { RawStmt: result };
122
+ }
123
+ /**
124
+ * Convert a v17 returningList into a v18 ReturningClause
125
+ */
126
+ transformReturningList(returningList, context) {
127
+ return {
128
+ exprs: returningList.map(item => this.transform(item, context))
129
+ };
130
+ }
131
+ transformDmlStatement(nodeType, node, context) {
132
+ const result = {};
133
+ for (const key of Object.keys(node)) {
134
+ if (key === 'returningList') {
135
+ result.returningClause = this.transformReturningList(node.returningList, context);
136
+ }
137
+ else {
138
+ result[key] = this.walkValue(node[key], context);
139
+ }
140
+ }
141
+ return { [nodeType]: result };
142
+ }
143
+ InsertStmt(node, context) {
144
+ return this.transformDmlStatement('InsertStmt', node, context);
145
+ }
146
+ UpdateStmt(node, context) {
147
+ return this.transformDmlStatement('UpdateStmt', node, context);
148
+ }
149
+ DeleteStmt(node, context) {
150
+ return this.transformDmlStatement('DeleteStmt', node, context);
151
+ }
152
+ MergeStmt(node, context) {
153
+ return this.transformDmlStatement('MergeStmt', node, context);
154
+ }
155
+ AlterTableCmd(node, context) {
156
+ const result = {};
157
+ for (const key of Object.keys(node)) {
158
+ result[key] = this.walkValue(node[key], context);
159
+ }
160
+ // v18 wraps ALTER CONSTRAINT definitions in the new ATAlterConstraint node
161
+ if (node.subtype === 'AT_AlterConstraint' && node.def?.Constraint) {
162
+ const constraint = node.def.Constraint;
163
+ const alterConstraint = {};
164
+ if (constraint.conname !== undefined) {
165
+ alterConstraint.conname = constraint.conname;
166
+ }
167
+ alterConstraint.is_enforced = true;
168
+ // v17 ALTER CONSTRAINT could only change deferrability
169
+ alterConstraint.alterDeferrability = true;
170
+ if (constraint.deferrable !== undefined) {
171
+ alterConstraint.deferrable = constraint.deferrable;
172
+ }
173
+ if (constraint.initdeferred !== undefined) {
174
+ alterConstraint.initdeferred = constraint.initdeferred;
175
+ }
176
+ result.def = { ATAlterConstraint: alterConstraint };
177
+ }
178
+ return { AlterTableCmd: result };
179
+ }
180
+ VariableSetStmt(node, context) {
181
+ const result = {};
182
+ for (const key of Object.keys(node)) {
183
+ result[key] = this.walkValue(node[key], context);
184
+ }
185
+ // v18 marks SET TRANSACTION / SESSION CHARACTERISTICS args as jumbled
186
+ if (node.kind === 'VAR_SET_MULTI' && (node.name === 'TRANSACTION' || node.name === 'SESSION CHARACTERISTICS')) {
187
+ result.jumble_args = true;
188
+ }
189
+ return { VariableSetStmt: result };
190
+ }
191
+ Constraint(node, context) {
192
+ const result = {};
193
+ for (const key of Object.keys(node)) {
194
+ result[key] = this.walkValue(node[key], context);
195
+ }
196
+ // v18 constraints are enforced by default; v17 grammar had no ENFORCED syntax
197
+ if (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_FOREIGN') {
198
+ result.is_enforced = true;
199
+ }
200
+ if (node.contype === 'CONSTR_NOTNULL') {
201
+ // v17 only produces column-level NOT NULL constraints, which in v18
202
+ // carry is_enforced and initially_valid
203
+ result.is_enforced = true;
204
+ result.initially_valid = true;
205
+ }
206
+ if (node.contype === 'CONSTR_GENERATED' && result.generated_kind === undefined) {
207
+ // v17 only supports STORED generated columns
208
+ result.generated_kind = 's';
209
+ }
210
+ return { Constraint: result };
211
+ }
212
+ }
213
+ exports.V17ToV18Transformer = V17ToV18Transformer;
package/deparser.d.ts DELETED
@@ -1,305 +0,0 @@
1
- import { Node } from '@pgsql/types';
2
- import { DeparserContext, DeparserVisitor } from './visitors/base';
3
- import * as t from '@pgsql/types';
4
- export interface DeparserOptions {
5
- newline?: string;
6
- tab?: string;
7
- functionDelimiter?: string;
8
- functionDelimiterFallback?: string;
9
- pretty?: boolean;
10
- }
11
- /**
12
- * Deparser - Converts PostgreSQL AST nodes back to SQL strings
13
- *
14
- * Entry Points:
15
- * 1. ParseResult (from libpg-query) - The complete parse result
16
- * Structure: { version: number, stmts: RawStmt[] }
17
- * Note: stmts is "repeated RawStmt" in protobuf, so array contains RawStmt
18
- * objects inline (not wrapped as { RawStmt: ... } nodes)
19
- * Example: { version: 170004, stmts: [{ stmt: {...}, stmt_len: 32 }] }
20
- *
21
- * 2. Wrapped ParseResult - When explicitly wrapped as a Node
22
- * Structure: { ParseResult: { version: number, stmts: RawStmt[] } }
23
- *
24
- * 3. Wrapped RawStmt - When explicitly wrapped as a Node
25
- * Structure: { RawStmt: { stmt: Node, stmt_len?: number } }
26
- *
27
- * 4. Array of Nodes - Multiple statements to deparse
28
- * Can be: Node[] (e.g., SelectStmt, InsertStmt, etc.)
29
- *
30
- * 5. Single Node - Individual statement node
31
- * Example: { SelectStmt: {...} }, { InsertStmt: {...} }, etc.
32
- *
33
- * The deparser automatically detects bare ParseResult objects for backward
34
- * compatibility and wraps them internally for consistent processing.
35
- */
36
- export declare class Deparser implements DeparserVisitor {
37
- private tree;
38
- private options;
39
- constructor(tree: Node | Node[] | t.ParseResult, opts?: DeparserOptions);
40
- /**
41
- * Static method to deparse PostgreSQL AST nodes to SQL
42
- * @param query - Can be:
43
- * - ParseResult from libpg-query (e.g., { version: 170004, stmts: [...] })
44
- * - Wrapped ParseResult node (e.g., { ParseResult: {...} })
45
- * - Wrapped RawStmt node (e.g., { RawStmt: {...} })
46
- * - Array of Nodes
47
- * - Single Node (e.g., { SelectStmt: {...} })
48
- * @param opts - Deparser options for formatting
49
- * @returns The deparsed SQL string
50
- */
51
- static deparse(query: Node | Node[] | t.ParseResult, opts?: DeparserOptions): string;
52
- deparseQuery(): string;
53
- /**
54
- * Get the appropriate function delimiter based on the body content
55
- * @param body The function body to check
56
- * @returns The delimiter to use
57
- */
58
- private getFunctionDelimiter;
59
- /**
60
- * Maps ObjectType enum values to their corresponding SQL keywords
61
- * Used by AlterOwnerStmt, AlterObjectSchemaStmt, and other statements that need object type keywords
62
- */
63
- private getObjectTypeKeyword;
64
- deparse(node: Node, context?: DeparserContext): string | null;
65
- visit(node: Node, context?: DeparserContext): string;
66
- getNodeType(node: Node): string;
67
- getNodeData(node: Node): any;
68
- ParseResult(node: t.ParseResult, context: DeparserContext): string;
69
- RawStmt(node: t.RawStmt, context: DeparserContext): string;
70
- SelectStmt(node: t.SelectStmt, context: DeparserContext): string;
71
- A_Expr(node: t.A_Expr, context: DeparserContext): string;
72
- deparseOperatorName(name: t.Node[], context: DeparserContext): string;
73
- private getOperatorPrecedence;
74
- private needsParentheses;
75
- private isComplexExpression;
76
- private isComplexSelectTarget;
77
- visitBetweenRange(rexpr: any, context: DeparserContext): string;
78
- InsertStmt(node: t.InsertStmt, context: DeparserContext): string;
79
- UpdateStmt(node: t.UpdateStmt, context: DeparserContext): string;
80
- DeleteStmt(node: t.DeleteStmt, context: DeparserContext): string;
81
- WithClause(node: t.WithClause, context: DeparserContext): string;
82
- ResTarget(node: t.ResTarget, context: DeparserContext): string;
83
- deparseReturningList(list: t.Node[], context: DeparserContext): string;
84
- BoolExpr(node: t.BoolExpr, context: DeparserContext): string;
85
- FuncCall(node: t.FuncCall, context: DeparserContext): string;
86
- FuncExpr(node: t.FuncExpr, context: DeparserContext): string;
87
- A_Const(node: t.A_Const, context: DeparserContext): string;
88
- ColumnRef(node: t.ColumnRef, context: DeparserContext): string;
89
- TypeName(node: t.TypeName, context: DeparserContext): string;
90
- Alias(node: t.Alias, context: DeparserContext): string;
91
- RangeVar(node: t.RangeVar, context: DeparserContext): string;
92
- formatIntervalTypeMods(typmods: t.Node[], context: DeparserContext): string | null;
93
- formatTypeMods(typmods: t.Node[], context: DeparserContext): string | null;
94
- formatSingleTypeMod(typemod: number, typeName: string): string | null;
95
- getPgCatalogTypeName(typeName: string, size: string | null): string;
96
- isPgCatalogType(typeName: string): boolean;
97
- A_ArrayExpr(node: t.A_ArrayExpr, context: DeparserContext): string;
98
- A_Indices(node: t.A_Indices, context: DeparserContext): string;
99
- A_Indirection(node: t.A_Indirection, context: DeparserContext): string;
100
- A_Star(node: t.A_Star, context: DeparserContext): string;
101
- CaseExpr(node: t.CaseExpr, context: DeparserContext): string;
102
- CoalesceExpr(node: t.CoalesceExpr, context: DeparserContext): string;
103
- TypeCast(node: t.TypeCast, context: DeparserContext): string;
104
- CollateClause(node: t.CollateClause, context: DeparserContext): string;
105
- BooleanTest(node: t.BooleanTest, context: DeparserContext): string;
106
- NullTest(node: t.NullTest, context: DeparserContext): string;
107
- quoteIfNeeded(value: string): string;
108
- preserveOperatorDefElemCase(defName: string): string;
109
- String(node: t.String, context: DeparserContext): string;
110
- Integer(node: t.Integer, context: DeparserContext): string;
111
- Float(node: t.Float, context: DeparserContext): string;
112
- Boolean(node: t.Boolean, context: DeparserContext): string;
113
- BitString(node: t.BitString, context: DeparserContext): string;
114
- Null(node: t.Node, context: DeparserContext): string;
115
- List(node: t.List, context: DeparserContext): string;
116
- CreateStmt(node: t.CreateStmt, context: DeparserContext): string;
117
- ColumnDef(node: t.ColumnDef, context: DeparserContext): string;
118
- Constraint(node: t.Constraint, context: DeparserContext): string;
119
- SubLink(node: t.SubLink, context: DeparserContext): string;
120
- CaseWhen(node: t.CaseWhen, context: DeparserContext): string;
121
- WindowDef(node: t.WindowDef, context: DeparserContext): string;
122
- formatWindowFrame(node: any, context: DeparserContext): string | null;
123
- SortBy(node: t.SortBy, context: DeparserContext): string;
124
- GroupingSet(node: t.GroupingSet, context: DeparserContext): string;
125
- CommonTableExpr(node: t.CommonTableExpr, context: DeparserContext): string;
126
- ParamRef(node: t.ParamRef, context: DeparserContext): string;
127
- LockingClause(node: any, context: DeparserContext): string;
128
- MinMaxExpr(node: t.MinMaxExpr, context: DeparserContext): string;
129
- RowExpr(node: t.RowExpr, context: DeparserContext): string;
130
- OpExpr(node: t.OpExpr, context: DeparserContext): string;
131
- DistinctExpr(node: t.DistinctExpr, context: DeparserContext): string;
132
- NullIfExpr(node: t.NullIfExpr, context: DeparserContext): string;
133
- ScalarArrayOpExpr(node: t.ScalarArrayOpExpr, context: DeparserContext): string;
134
- Aggref(node: t.Aggref, context: DeparserContext): string;
135
- WindowFunc(node: t.WindowFunc, context: DeparserContext): string;
136
- FieldSelect(node: t.FieldSelect, context: DeparserContext): string;
137
- RelabelType(node: t.RelabelType, context: DeparserContext): string;
138
- CoerceViaIO(node: t.CoerceViaIO, context: DeparserContext): string;
139
- ArrayCoerceExpr(node: t.ArrayCoerceExpr, context: DeparserContext): string;
140
- ConvertRowtypeExpr(node: t.ConvertRowtypeExpr, context: DeparserContext): string;
141
- NamedArgExpr(node: t.NamedArgExpr, context: DeparserContext): string;
142
- ViewStmt(node: t.ViewStmt, context: DeparserContext): string;
143
- IndexStmt(node: t.IndexStmt, context: DeparserContext): string;
144
- IndexElem(node: t.IndexElem, context: DeparserContext): string;
145
- PartitionElem(node: t.PartitionElem, context: DeparserContext): string;
146
- PartitionCmd(node: t.PartitionCmd, context: DeparserContext): string;
147
- private getAggFunctionName;
148
- private getWindowFunctionName;
149
- private getOperatorName;
150
- JoinExpr(node: t.JoinExpr, context: DeparserContext): string;
151
- FromExpr(node: t.FromExpr, context: DeparserContext): string;
152
- TransactionStmt(node: t.TransactionStmt, context: DeparserContext): string;
153
- VariableSetStmt(node: t.VariableSetStmt, context: DeparserContext): string;
154
- VariableShowStmt(node: t.VariableShowStmt, context: DeparserContext): string;
155
- CreateSchemaStmt(node: t.CreateSchemaStmt, context: DeparserContext): string;
156
- RoleSpec(node: t.RoleSpec, context: DeparserContext): string;
157
- roletype(node: any, context: DeparserContext): string;
158
- DropStmt(node: t.DropStmt, context: DeparserContext): string;
159
- TruncateStmt(node: t.TruncateStmt, context: DeparserContext): string;
160
- ReturnStmt(node: t.ReturnStmt, context: DeparserContext): string;
161
- PLAssignStmt(node: t.PLAssignStmt, context: DeparserContext): string;
162
- CopyStmt(node: t.CopyStmt, context: DeparserContext): string;
163
- AlterTableStmt(node: t.AlterTableStmt, context: DeparserContext): string;
164
- AlterTableCmd(node: t.AlterTableCmd, context: DeparserContext): string;
165
- CreateFunctionStmt(node: t.CreateFunctionStmt, context: DeparserContext): string;
166
- FunctionParameter(node: t.FunctionParameter, context: DeparserContext): string;
167
- CreateEnumStmt(node: t.CreateEnumStmt, context: DeparserContext): string;
168
- CreateDomainStmt(node: t.CreateDomainStmt, context: DeparserContext): string;
169
- CreateRoleStmt(node: t.CreateRoleStmt, context: DeparserContext): string;
170
- DefElem(node: t.DefElem, context: DeparserContext): string;
171
- CreateTableSpaceStmt(node: t.CreateTableSpaceStmt, context: DeparserContext): string;
172
- DropTableSpaceStmt(node: t.DropTableSpaceStmt, context: DeparserContext): string;
173
- AlterTableSpaceOptionsStmt(node: t.AlterTableSpaceOptionsStmt, context: DeparserContext): string;
174
- CreateExtensionStmt(node: t.CreateExtensionStmt, context: DeparserContext): string;
175
- AlterExtensionStmt(node: t.AlterExtensionStmt, context: DeparserContext): string;
176
- AlterExtensionContentsStmt(node: t.AlterExtensionContentsStmt, context: DeparserContext): string;
177
- CreateFdwStmt(node: t.CreateFdwStmt, context: DeparserContext): string;
178
- SetOperationStmt(node: t.SetOperationStmt, context: DeparserContext): string;
179
- ReplicaIdentityStmt(node: t.ReplicaIdentityStmt, context: DeparserContext): string;
180
- AlterCollationStmt(node: t.AlterCollationStmt, context: DeparserContext): string;
181
- AlterDomainStmt(node: t.AlterDomainStmt, context: DeparserContext): string;
182
- PrepareStmt(node: t.PrepareStmt, context: DeparserContext): string;
183
- ExecuteStmt(node: t.ExecuteStmt, context: DeparserContext): string;
184
- DeallocateStmt(node: t.DeallocateStmt, context: DeparserContext): string;
185
- NotifyStmt(node: t.NotifyStmt, context: DeparserContext): string;
186
- ListenStmt(node: t.ListenStmt, context: DeparserContext): string;
187
- UnlistenStmt(node: t.UnlistenStmt, context: DeparserContext): string;
188
- CheckPointStmt(node: t.CheckPointStmt, context: DeparserContext): string;
189
- LoadStmt(node: t.LoadStmt, context: DeparserContext): string;
190
- DiscardStmt(node: t.DiscardStmt, context: DeparserContext): string;
191
- CommentStmt(node: t.CommentStmt, context: DeparserContext): string;
192
- LockStmt(node: t.LockStmt, context: DeparserContext): string;
193
- CreatePolicyStmt(node: t.CreatePolicyStmt, context: DeparserContext): string;
194
- AlterPolicyStmt(node: t.AlterPolicyStmt, context: DeparserContext): string;
195
- CreateUserMappingStmt(node: t.CreateUserMappingStmt, context: DeparserContext): string;
196
- CreateStatsStmt(node: t.CreateStatsStmt, context: DeparserContext): string;
197
- StatsElem(node: t.StatsElem, context: DeparserContext): string;
198
- CreatePublicationStmt(node: t.CreatePublicationStmt, context: DeparserContext): string;
199
- CreateSubscriptionStmt(node: t.CreateSubscriptionStmt, context: DeparserContext): string;
200
- AlterPublicationStmt(node: t.AlterPublicationStmt, context: DeparserContext): string;
201
- AlterSubscriptionStmt(node: t.AlterSubscriptionStmt, context: DeparserContext): string;
202
- DropSubscriptionStmt(node: t.DropSubscriptionStmt, context: DeparserContext): string;
203
- DoStmt(node: t.DoStmt, context: DeparserContext): string;
204
- private generateUniqueDollarTag;
205
- InlineCodeBlock(node: t.InlineCodeBlock, context: DeparserContext): string;
206
- CallContext(node: t.CallContext, context: DeparserContext): string;
207
- ConstraintsSetStmt(node: t.ConstraintsSetStmt, context: DeparserContext): string;
208
- AlterSystemStmt(node: t.AlterSystemStmt, context: DeparserContext): string;
209
- VacuumRelation(node: t.VacuumRelation, context: DeparserContext): string;
210
- DropOwnedStmt(node: t.DropOwnedStmt, context: DeparserContext): string;
211
- ReassignOwnedStmt(node: t.ReassignOwnedStmt, context: DeparserContext): string;
212
- AlterTSDictionaryStmt(node: t.AlterTSDictionaryStmt, context: DeparserContext): string;
213
- AlterTSConfigurationStmt(node: t.AlterTSConfigurationStmt, context: DeparserContext): string;
214
- ClosePortalStmt(node: t.ClosePortalStmt, context: DeparserContext): string;
215
- FetchStmt(node: t.FetchStmt, context: DeparserContext): string;
216
- AlterStatsStmt(node: t.AlterStatsStmt, context: DeparserContext): string;
217
- ObjectWithArgs(node: t.ObjectWithArgs, context: DeparserContext): string;
218
- AlterOperatorStmt(node: t.AlterOperatorStmt, context: DeparserContext): string;
219
- AlterFdwStmt(node: t.AlterFdwStmt, context: DeparserContext): string;
220
- CreateForeignServerStmt(node: t.CreateForeignServerStmt, context: DeparserContext): string;
221
- AlterForeignServerStmt(node: t.AlterForeignServerStmt, context: DeparserContext): string;
222
- AlterUserMappingStmt(node: t.AlterUserMappingStmt, context: DeparserContext): string;
223
- DropUserMappingStmt(node: t.DropUserMappingStmt, context: DeparserContext): string;
224
- ImportForeignSchemaStmt(node: t.ImportForeignSchemaStmt, context: DeparserContext): string;
225
- ClusterStmt(node: t.ClusterStmt, context: DeparserContext): string;
226
- VacuumStmt(node: t.VacuumStmt, context: DeparserContext): string;
227
- ExplainStmt(node: t.ExplainStmt, context: DeparserContext): string;
228
- ReindexStmt(node: t.ReindexStmt, context: DeparserContext): string;
229
- CallStmt(node: t.CallStmt, context: DeparserContext): string;
230
- CreatedbStmt(node: t.CreatedbStmt, context: DeparserContext): string;
231
- DropdbStmt(node: t.DropdbStmt, context: DeparserContext): string;
232
- RenameStmt(node: t.RenameStmt, context: DeparserContext): string;
233
- AlterOwnerStmt(node: t.AlterOwnerStmt, context: DeparserContext): string;
234
- GrantStmt(node: t.GrantStmt, context: DeparserContext): string;
235
- GrantRoleStmt(node: t.GrantRoleStmt, context: DeparserContext): string;
236
- SecLabelStmt(node: t.SecLabelStmt, context: DeparserContext): string;
237
- AlterDefaultPrivilegesStmt(node: t.AlterDefaultPrivilegesStmt, context: DeparserContext): string;
238
- CreateConversionStmt(node: t.CreateConversionStmt, context: DeparserContext): string;
239
- CreateCastStmt(node: t.CreateCastStmt, context: DeparserContext): string;
240
- CreatePLangStmt(node: t.CreatePLangStmt, context: DeparserContext): string;
241
- CreateTransformStmt(node: t.CreateTransformStmt, context: DeparserContext): string;
242
- CreateTrigStmt(node: t.CreateTrigStmt, context: DeparserContext): string;
243
- TriggerTransition(node: t.TriggerTransition, context: DeparserContext): string;
244
- CreateEventTrigStmt(node: t.CreateEventTrigStmt, context: DeparserContext): string;
245
- AlterEventTrigStmt(node: t.AlterEventTrigStmt, context: DeparserContext): string;
246
- CreateOpClassStmt(node: t.CreateOpClassStmt, context: DeparserContext): string;
247
- CreateOpFamilyStmt(node: t.CreateOpFamilyStmt, context: DeparserContext): string;
248
- AlterOpFamilyStmt(node: t.AlterOpFamilyStmt, context: DeparserContext): string;
249
- MergeStmt(node: t.MergeStmt, context: DeparserContext): string;
250
- MergeWhenClause(node: t.MergeWhenClause, context: DeparserContext): string;
251
- AlterTableMoveAllStmt(node: t.AlterTableMoveAllStmt, context: DeparserContext): string;
252
- CreateSeqStmt(node: t.CreateSeqStmt, context: DeparserContext): string;
253
- AlterSeqStmt(node: t.AlterSeqStmt, context: DeparserContext): string;
254
- CompositeTypeStmt(node: t.CompositeTypeStmt, context: DeparserContext): string;
255
- CreateRangeStmt(node: t.CreateRangeStmt, context: DeparserContext): string;
256
- AlterEnumStmt(node: t.AlterEnumStmt, context: DeparserContext): string;
257
- AlterTypeStmt(node: t.AlterTypeStmt, context: DeparserContext): string;
258
- AlterRoleStmt(node: t.AlterRoleStmt, context: DeparserContext): string;
259
- DropRoleStmt(node: t.DropRoleStmt, context: DeparserContext): string;
260
- targetList(node: any, context: DeparserContext): string;
261
- CreateAggregateStmt(node: t.DefineStmt, context: DeparserContext): string;
262
- CreateTableAsStmt(node: t.CreateTableAsStmt, context: DeparserContext): string;
263
- RefreshMatViewStmt(node: t.RefreshMatViewStmt, context: DeparserContext): string;
264
- AccessPriv(node: t.AccessPriv, context: DeparserContext): string;
265
- aliasname(node: any, context: DeparserContext): string;
266
- DefineStmt(node: t.DefineStmt, context: DeparserContext): string;
267
- AlterDatabaseStmt(node: t.AlterDatabaseStmt, context: DeparserContext): string;
268
- AlterDatabaseRefreshCollStmt(node: t.AlterDatabaseRefreshCollStmt, context: DeparserContext): string;
269
- AlterDatabaseSetStmt(node: t.AlterDatabaseSetStmt, context: DeparserContext): string;
270
- DeclareCursorStmt(node: t.DeclareCursorStmt, context: DeparserContext): string;
271
- PublicationObjSpec(node: t.PublicationObjSpec, context: DeparserContext): string;
272
- PublicationTable(node: t.PublicationTable, context: DeparserContext): string;
273
- CreateAmStmt(node: t.CreateAmStmt, context: DeparserContext): string;
274
- IntoClause(node: t.IntoClause, context: DeparserContext): string;
275
- OnConflictExpr(node: t.OnConflictExpr, context: DeparserContext): string;
276
- ScanToken(node: t.ScanToken, context: DeparserContext): string;
277
- CreateOpClassItem(node: t.CreateOpClassItem, context: DeparserContext): string;
278
- Var(node: t.Var, context: DeparserContext): string;
279
- TableFunc(node: t.TableFunc, context: DeparserContext): string;
280
- RangeTableFunc(node: t.RangeTableFunc, context: DeparserContext): string;
281
- RangeTableFuncCol(node: t.RangeTableFuncCol, context: DeparserContext): string;
282
- JsonArrayQueryConstructor(node: t.JsonArrayQueryConstructor, context: DeparserContext): string;
283
- RangeFunction(node: t.RangeFunction, context: DeparserContext): string;
284
- XmlExpr(node: t.XmlExpr, context: DeparserContext): string;
285
- schemaname(node: any, context: DeparserContext): string;
286
- RangeTableSample(node: t.RangeTableSample, context: DeparserContext): string;
287
- XmlSerialize(node: t.XmlSerialize, context: DeparserContext): string;
288
- ctes(node: any, context: DeparserContext): string;
289
- RuleStmt(node: t.RuleStmt, context: DeparserContext): string;
290
- RangeSubselect(node: t.RangeSubselect, context: DeparserContext): string;
291
- relname(node: any, context: DeparserContext): string;
292
- rel(node: any, context: DeparserContext): string;
293
- objname(node: any, context: DeparserContext): string;
294
- SQLValueFunction(node: t.SQLValueFunction, context: DeparserContext): string;
295
- GroupingFunc(node: t.GroupingFunc, context: DeparserContext): string;
296
- MultiAssignRef(node: t.MultiAssignRef, context: DeparserContext): string;
297
- SetToDefault(node: t.SetToDefault, context: DeparserContext): string;
298
- CurrentOfExpr(node: t.CurrentOfExpr, context: DeparserContext): string;
299
- TableLikeClause(node: t.TableLikeClause, context: DeparserContext): string;
300
- AlterFunctionStmt(node: t.AlterFunctionStmt, context: DeparserContext): string;
301
- AlterObjectSchemaStmt(node: t.AlterObjectSchemaStmt, context: DeparserContext): string;
302
- AlterRoleSetStmt(node: t.AlterRoleSetStmt, context: DeparserContext): string;
303
- CreateForeignTableStmt(node: t.CreateForeignTableStmt, context: DeparserContext): string;
304
- private containsMultilineStringLiteral;
305
- }
@@ -1,32 +0,0 @@
1
- export class SqlFormatter {
2
- newlineChar;
3
- tabChar;
4
- prettyMode;
5
- constructor(newlineChar = '\n', tabChar = ' ', prettyMode = true) {
6
- this.newlineChar = newlineChar;
7
- this.tabChar = tabChar;
8
- this.prettyMode = prettyMode;
9
- }
10
- format(parts, separator = ' ') {
11
- return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
12
- }
13
- indent(text, count = 1) {
14
- if (!this.prettyMode) {
15
- return text;
16
- }
17
- const indentation = this.tabChar.repeat(count);
18
- return text.split(this.newlineChar).map(line => line.trim() ? indentation + line : line).join(this.newlineChar);
19
- }
20
- parens(content) {
21
- return `(${content})`;
22
- }
23
- newline() {
24
- return this.newlineChar;
25
- }
26
- tab() {
27
- return this.tabChar;
28
- }
29
- isPretty() {
30
- return this.prettyMode;
31
- }
32
- }
@@ -1,12 +0,0 @@
1
- export declare class SqlFormatter {
2
- private newlineChar;
3
- private tabChar;
4
- private prettyMode;
5
- constructor(newlineChar?: string, tabChar?: string, prettyMode?: boolean);
6
- format(parts: string[], separator?: string): string;
7
- indent(text: string, count?: number): string;
8
- parens(content: string): string;
9
- newline(): string;
10
- tab(): string;
11
- isPretty(): boolean;
12
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SqlFormatter = void 0;
4
- class SqlFormatter {
5
- newlineChar;
6
- tabChar;
7
- prettyMode;
8
- constructor(newlineChar = '\n', tabChar = ' ', prettyMode = true) {
9
- this.newlineChar = newlineChar;
10
- this.tabChar = tabChar;
11
- this.prettyMode = prettyMode;
12
- }
13
- format(parts, separator = ' ') {
14
- return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
15
- }
16
- indent(text, count = 1) {
17
- if (!this.prettyMode) {
18
- return text;
19
- }
20
- const indentation = this.tabChar.repeat(count);
21
- return text.split(this.newlineChar).map(line => line.trim() ? indentation + line : line).join(this.newlineChar);
22
- }
23
- parens(content) {
24
- return `(${content})`;
25
- }
26
- newline() {
27
- return this.newlineChar;
28
- }
29
- tab() {
30
- return this.tabChar;
31
- }
32
- isPretty() {
33
- return this.prettyMode;
34
- }
35
- }
36
- exports.SqlFormatter = SqlFormatter;