pgsql-deparser 13.18.0 → 13.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/deparser/deparser.d.ts +302 -0
  3. package/deparser/deparser.js +10451 -0
  4. package/deparser/index.d.ts +9 -0
  5. package/deparser/index.js +17 -0
  6. package/deparser/utils/list-utils.d.ts +8 -0
  7. package/deparser/utils/list-utils.js +30 -0
  8. package/deparser/utils/quote-utils.d.ts +24 -0
  9. package/deparser/utils/quote-utils.js +89 -0
  10. package/deparser/utils/sql-formatter.d.ts +16 -0
  11. package/deparser/utils/sql-formatter.js +40 -0
  12. package/deparser/visitors/base.d.ts +68 -0
  13. package/deparser/visitors/base.js +122 -0
  14. package/{src/deparser/deparser.ts → esm/deparser/deparser.js} +589 -616
  15. package/{src/deparser/index.ts → esm/deparser/index.js} +3 -4
  16. package/{src/deparser/utils/list-utils.ts → esm/deparser/utils/list-utils.js} +2 -3
  17. package/{src/deparser/utils/quote-utils.ts → esm/deparser/utils/quote-utils.js} +6 -7
  18. package/{src/deparser/utils/sql-formatter.ts → esm/deparser/utils/sql-formatter.js} +10 -11
  19. package/{src/deparser/visitors/base.ts → esm/deparser/visitors/base.js} +34 -62
  20. package/esm/index.js +15 -0
  21. package/{src/v13-to-v14.ts → esm/v13-to-v14.js} +472 -609
  22. package/{src/v13-to-v17-direct.ts → esm/v13-to-v17-direct.js} +11 -12
  23. package/{src/v14-to-v15.ts → esm/v14-to-v15.js} +261 -662
  24. package/{src/v15-to-v16.ts → esm/v15-to-v16.js} +814 -1229
  25. package/esm/v16-to-v17.js +1488 -0
  26. package/index.d.ts +9 -0
  27. package/index.js +19 -0
  28. package/package.json +1 -1
  29. package/v13-to-v14.d.ts +253 -0
  30. package/v13-to-v14.js +2754 -0
  31. package/v13-to-v17-direct.d.ts +24 -0
  32. package/v13-to-v17-direct.js +82 -0
  33. package/v14-to-v15.d.ts +616 -0
  34. package/v14-to-v15.js +1227 -0
  35. package/v15-to-v16.d.ts +633 -0
  36. package/v15-to-v16.js +2944 -0
  37. package/v16-to-v17.d.ts +638 -0
  38. package/v16-to-v17.js +1492 -0
  39. package/src/index.ts +0 -27
  40. package/src/v16-to-v17.ts +0 -1897
  41. package/tsconfig.esm.json +0 -8
  42. package/tsconfig.json +0 -26
@@ -2,8 +2,7 @@
2
2
  * Auto-generated file with types stripped for better tree-shaking
3
3
  * DO NOT EDIT - Generated by strip-deparser-types.ts
4
4
  */
5
-
6
- import { DeparserContext, DeparserVisitor } from './visitors/base';
5
+ import { DeparserContext } from './visitors/base';
7
6
  import { SqlFormatter } from './utils/sql-formatter';
8
7
  import { QuoteUtils } from './utils/quote-utils';
9
8
  import { ListUtils } from './utils/list-utils';
@@ -56,27 +55,15 @@ const pgCatalogTypes = [
56
55
  * but not present in pg_catalog.pg_type. These are resolved to
57
56
  * real types during parsing and never appear in introspection.
58
57
  */
59
- const pgCatalogTypeAliases: [
60
- string,
61
- string[]
62
- ][] = [
58
+ const pgCatalogTypeAliases = [
63
59
  ['numeric', ['decimal', 'dec']],
64
60
  ['int4', ['int', 'integer']],
65
61
  ['float8', ['float']],
66
62
  ['bpchar', ['character']],
67
63
  ['varchar', ['character varying']]
68
64
  ];
69
- export interface DeparserOptions {
70
- newline?: string;
71
- tab?: string;
72
- // Function body delimiter options
73
- functionDelimiter?: string; // Default: '$$'
74
- // Alternative delimiter when the default is found in the body
75
- functionDelimiterFallback?: string; // Default: '$EOFCODE$'
76
- pretty?: boolean; // Default: true
77
- }
78
65
  // Type guards for better type safety
79
- function isParseResult(obj: any): obj is any {
66
+ function isParseResult(obj) {
80
67
  // A ParseResult is an object that could have stmts (but not required)
81
68
  // and is not already wrapped as a Node
82
69
  // IMPORTANT: ParseResult.stmts is "repeated RawStmt" in protobuf, meaning
@@ -89,9 +76,7 @@ function isParseResult(obj: any): obj is any {
89
76
  // Check if it looks like a ParseResult (has stmts or version)
90
77
  ('stmts' in obj || 'version' in obj);
91
78
  }
92
- function isWrappedParseResult(obj: any): obj is {
93
- ParseResult: any;
94
- } {
79
+ function isWrappedParseResult(obj) {
95
80
  return obj && typeof obj === 'object' && 'ParseResult' in obj;
96
81
  }
97
82
  /**
@@ -119,10 +104,10 @@ function isWrappedParseResult(obj: any): obj is {
119
104
  * The deparser automatically detects bare ParseResult objects for backward
120
105
  * compatibility and wraps them internally for consistent processing.
121
106
  */
122
- export class Deparser implements DeparserVisitor {
123
- private tree: any[];
124
- private options: DeparserOptions;
125
- constructor(tree: any | any[] | any, opts: DeparserOptions = {}) {
107
+ export class Deparser {
108
+ tree;
109
+ options;
110
+ constructor(tree, opts = {}) {
126
111
  // Set default options
127
112
  this.options = {
128
113
  functionDelimiter: '$$',
@@ -155,10 +140,10 @@ export class Deparser implements DeparserVisitor {
155
140
  * @param opts - Deparser options for formatting
156
141
  * @returns The deparsed SQL string
157
142
  */
158
- static deparse(query: any | any[] | any, opts: DeparserOptions = {}): string {
143
+ static deparse(query, opts = {}) {
159
144
  return new Deparser(query, opts).deparseQuery();
160
145
  }
161
- deparseQuery(): string {
146
+ deparseQuery() {
162
147
  const formatter = new SqlFormatter(this.options.newline, this.options.tab, this.options.pretty);
163
148
  const context = new DeparserContext({ formatter, prettyMode: this.options.pretty });
164
149
  return this.tree
@@ -176,14 +161,14 @@ export class Deparser implements DeparserVisitor {
176
161
  * @param body The function body to check
177
162
  * @returns The delimiter to use
178
163
  */
179
- private getFunctionDelimiter(body: string): string {
164
+ getFunctionDelimiter(body) {
180
165
  const delimiter = this.options.functionDelimiter || '$$';
181
166
  if (body.includes(delimiter)) {
182
167
  return this.options.functionDelimiterFallback || '$EOFCODE$';
183
168
  }
184
169
  return delimiter;
185
170
  }
186
- deparse(node: any, context?: DeparserContext): string | null {
171
+ deparse(node, context) {
187
172
  if (node == null) {
188
173
  return null;
189
174
  }
@@ -199,10 +184,10 @@ export class Deparser implements DeparserVisitor {
199
184
  }
200
185
  catch (error) {
201
186
  const nodeType = Object.keys(node)[0];
202
- throw new Error(`Error deparsing ${nodeType}: ${(error as Error).message}`);
187
+ throw new Error(`Error deparsing ${nodeType}: ${error.message}`);
203
188
  }
204
189
  }
205
- visit(node: any, context?: DeparserContext): string {
190
+ visit(node, context) {
206
191
  if (!context) {
207
192
  const formatter = new SqlFormatter(this.options.newline, this.options.tab, this.options.pretty);
208
193
  context = new DeparserContext({ formatter, prettyMode: this.options.pretty });
@@ -213,24 +198,24 @@ export class Deparser implements DeparserVisitor {
213
198
  return '';
214
199
  }
215
200
  const nodeData = this.getNodeData(node);
216
- const methodName = nodeType as keyof this;
201
+ const methodName = nodeType;
217
202
  if (typeof this[methodName] === 'function') {
218
- const result = (this[methodName] as any)(nodeData, context);
203
+ const result = this[methodName](nodeData, context);
219
204
  return result;
220
205
  }
221
206
  throw new Error(`Deparser does not handle node type: ${nodeType}`);
222
207
  }
223
- getNodeType(node: any): string {
208
+ getNodeType(node) {
224
209
  return Object.keys(node)[0];
225
210
  }
226
- getNodeData(node: any): any {
211
+ getNodeData(node) {
227
212
  const keys = Object.keys(node);
228
- if (keys.length === 1 && typeof (node as any)[keys[0]] === 'object') {
229
- return (node as any)[keys[0]];
213
+ if (keys.length === 1 && typeof node[keys[0]] === 'object') {
214
+ return node[keys[0]];
230
215
  }
231
216
  return node;
232
217
  }
233
- ParseResult(node: any, context: DeparserContext): string {
218
+ ParseResult(node, context) {
234
219
  if (!node.stmts || node.stmts.length === 0) {
235
220
  return '';
236
221
  }
@@ -238,12 +223,12 @@ export class Deparser implements DeparserVisitor {
238
223
  // Note: node.stmts is "repeated RawStmt" so contains RawStmt objects inline
239
224
  // Each element has structure: { stmt: Node, stmt_len?: number, stmt_location?: number }
240
225
  return node.stmts
241
- .filter((rawStmt: any) => rawStmt != null)
242
- .map((rawStmt: any) => this.RawStmt(rawStmt, context))
243
- .filter((result: string) => result !== '')
226
+ .filter((rawStmt) => rawStmt != null)
227
+ .map((rawStmt) => this.RawStmt(rawStmt, context))
228
+ .filter((result) => result !== '')
244
229
  .join(context.newline() + context.newline());
245
230
  }
246
- RawStmt(node: any, context: DeparserContext): string {
231
+ RawStmt(node, context) {
247
232
  if (!node.stmt) {
248
233
  return '';
249
234
  }
@@ -254,8 +239,8 @@ export class Deparser implements DeparserVisitor {
254
239
  }
255
240
  return deparsedStmt;
256
241
  }
257
- SelectStmt(node: any, context: DeparserContext): string {
258
- const output: string[] = [];
242
+ SelectStmt(node, context) {
243
+ const output = [];
259
244
  if (node.withClause) {
260
245
  output.push(this.WithClause(node.withClause, context));
261
246
  }
@@ -518,8 +503,8 @@ export class Deparser implements DeparserVisitor {
518
503
  }
519
504
  return output.join(' ');
520
505
  }
521
- A_Expr(node: any, context: DeparserContext): string {
522
- const kind = node.kind as string;
506
+ A_Expr(node, context) {
507
+ const kind = node.kind;
523
508
  const name = ListUtils.unwrapList(node.name);
524
509
  const lexpr = node.lexpr;
525
510
  const rexpr = node.rexpr;
@@ -670,11 +655,11 @@ export class Deparser implements DeparserVisitor {
670
655
  }
671
656
  case 'AEXPR_SIMILAR':
672
657
  const similarOp = this.deparseOperatorName(name, context);
673
- let rightExpr: string;
658
+ let rightExpr;
674
659
  if (rexpr && 'FuncCall' in rexpr &&
675
660
  rexpr.FuncCall?.funcname?.length === 2 &&
676
- (rexpr.FuncCall.funcname[0] as any)?.String?.sval === 'pg_catalog' &&
677
- (rexpr.FuncCall.funcname[1] as any)?.String?.sval === 'similar_to_escape') {
661
+ rexpr.FuncCall.funcname[0]?.String?.sval === 'pg_catalog' &&
662
+ rexpr.FuncCall.funcname[1]?.String?.sval === 'similar_to_escape') {
678
663
  const args = rexpr.FuncCall.args || [];
679
664
  rightExpr = this.visit(args[0], context);
680
665
  if (args.length > 1) {
@@ -725,11 +710,11 @@ export class Deparser implements DeparserVisitor {
725
710
  }
726
711
  throw new Error(`Unhandled A_Expr kind: ${kind}`);
727
712
  }
728
- deparseOperatorName(name: any, context: DeparserContext): string {
713
+ deparseOperatorName(name, context) {
729
714
  if (!name || name.length === 0) {
730
715
  return '';
731
716
  }
732
- const parts = name.map((n: any) => {
717
+ const parts = name.map((n) => {
733
718
  if (n.String) {
734
719
  return n.String.sval || n.String.str;
735
720
  }
@@ -740,10 +725,8 @@ export class Deparser implements DeparserVisitor {
740
725
  }
741
726
  return parts.join('.');
742
727
  }
743
- private getOperatorPrecedence(operator: string): number {
744
- const precedence: {
745
- [key: string]: number;
746
- } = {
728
+ getOperatorPrecedence(operator) {
729
+ const precedence = {
747
730
  '||': 1, // string concatenation
748
731
  'OR': 2, // logical OR
749
732
  'AND': 3, // logical AND
@@ -776,7 +759,7 @@ export class Deparser implements DeparserVisitor {
776
759
  };
777
760
  return precedence[operator] || 0;
778
761
  }
779
- private needsParentheses(childOp: string, parentOp: string, position: 'left' | 'right'): boolean {
762
+ needsParentheses(childOp, parentOp, position) {
780
763
  const childPrec = this.getOperatorPrecedence(childOp);
781
764
  const parentPrec = this.getOperatorPrecedence(parentOp);
782
765
  if (childPrec < parentPrec) {
@@ -789,7 +772,7 @@ export class Deparser implements DeparserVisitor {
789
772
  }
790
773
  return false;
791
774
  }
792
- private isComplexExpression(node: any): boolean {
775
+ isComplexExpression(node) {
793
776
  return !!(node.NullTest ||
794
777
  node.BooleanTest ||
795
778
  node.BoolExpr ||
@@ -798,7 +781,7 @@ export class Deparser implements DeparserVisitor {
798
781
  node.SubLink ||
799
782
  node.A_Expr);
800
783
  }
801
- private isComplexSelectTarget(node: any): boolean {
784
+ isComplexSelectTarget(node) {
802
785
  if (!node)
803
786
  return false;
804
787
  if (node.ResTarget?.val) {
@@ -856,15 +839,15 @@ export class Deparser implements DeparserVisitor {
856
839
  }
857
840
  return false;
858
841
  }
859
- visitBetweenRange(rexpr: any, context: DeparserContext): string {
842
+ visitBetweenRange(rexpr, context) {
860
843
  if (rexpr && 'List' in rexpr && rexpr.List?.items) {
861
- const items = rexpr.List.items.map((item: any) => this.visit(item, context));
844
+ const items = rexpr.List.items.map((item) => this.visit(item, context));
862
845
  return items.join(' AND ');
863
846
  }
864
847
  return this.visit(rexpr, context);
865
848
  }
866
- InsertStmt(node: any, context: DeparserContext): string {
867
- const output: string[] = [];
849
+ InsertStmt(node, context) {
850
+ const output = [];
868
851
  if (node.withClause) {
869
852
  output.push(this.WithClause(node.withClause, context));
870
853
  }
@@ -945,8 +928,8 @@ export class Deparser implements DeparserVisitor {
945
928
  }
946
929
  return output.join(' ');
947
930
  }
948
- UpdateStmt(node: any, context: DeparserContext): string {
949
- const output: string[] = [];
931
+ UpdateStmt(node, context) {
932
+ const output = [];
950
933
  if (node.withClause) {
951
934
  output.push(this.WithClause(node.withClause, context));
952
935
  }
@@ -1004,9 +987,9 @@ export class Deparser implements DeparserVisitor {
1004
987
  }
1005
988
  return output.join(' ');
1006
989
  }
1007
- DeleteStmt(node: any, context: DeparserContext): string {
990
+ DeleteStmt(node, context) {
1008
991
  try {
1009
- const output: string[] = [];
992
+ const output = [];
1010
993
  if (node.withClause) {
1011
994
  try {
1012
995
  output.push(this.WithClause(node.withClause, context));
@@ -1067,8 +1050,8 @@ export class Deparser implements DeparserVisitor {
1067
1050
  throw new Error(`Error deparsing DeleteStmt: ${error instanceof Error ? error.message : String(error)}`);
1068
1051
  }
1069
1052
  }
1070
- WithClause(node: any, context: DeparserContext): string {
1071
- const output: string[] = ['WITH'];
1053
+ WithClause(node, context) {
1054
+ const output = ['WITH'];
1072
1055
  if (node.recursive) {
1073
1056
  output.push('RECURSIVE');
1074
1057
  }
@@ -1092,8 +1075,8 @@ export class Deparser implements DeparserVisitor {
1092
1075
  }
1093
1076
  return output.join(' ');
1094
1077
  }
1095
- ResTarget(node: any, context: DeparserContext): string {
1096
- const output: string[] = [];
1078
+ ResTarget(node, context) {
1079
+ const output = [];
1097
1080
  if (context.update && node.name) {
1098
1081
  output.push(QuoteUtils.quote(node.name));
1099
1082
  // Handle indirection (array indexing, field access, etc.)
@@ -1135,14 +1118,14 @@ export class Deparser implements DeparserVisitor {
1135
1118
  }
1136
1119
  return output.join(' ');
1137
1120
  }
1138
- deparseReturningList(list: any, context: DeparserContext): string {
1121
+ deparseReturningList(list, context) {
1139
1122
  return ListUtils.unwrapList(list)
1140
1123
  .filter(item => item != null && this.getNodeType(item) !== 'undefined')
1141
1124
  .map(item => {
1142
1125
  try {
1143
1126
  // Handle ResTarget wrapper
1144
1127
  if (this.getNodeType(item) === 'ResTarget') {
1145
- const resTarget = this.getNodeData(item) as any;
1128
+ const resTarget = this.getNodeData(item);
1146
1129
  const val = resTarget.val ? this.visit(resTarget.val, context) : '';
1147
1130
  const alias = resTarget.name ? ` AS ${QuoteUtils.quote(resTarget.name)}` : '';
1148
1131
  return val + alias;
@@ -1160,8 +1143,8 @@ export class Deparser implements DeparserVisitor {
1160
1143
  .filter(item => item && item.trim())
1161
1144
  .join(', ');
1162
1145
  }
1163
- BoolExpr(node: any, context: DeparserContext): string {
1164
- const boolop = node.boolop as string;
1146
+ BoolExpr(node, context) {
1147
+ const boolop = node.boolop;
1165
1148
  const args = ListUtils.unwrapList(node.args);
1166
1149
  let formatStr = '%s';
1167
1150
  if (context.bool) {
@@ -1196,7 +1179,7 @@ export class Deparser implements DeparserVisitor {
1196
1179
  throw new Error(`Unhandled BoolExpr boolop: ${boolop}`);
1197
1180
  }
1198
1181
  }
1199
- FuncCall(node: any, context: DeparserContext): string {
1182
+ FuncCall(node, context) {
1200
1183
  const funcname = ListUtils.unwrapList(node.funcname);
1201
1184
  const args = ListUtils.unwrapList(node.args);
1202
1185
  const name = funcname.map(n => this.visit(n, context)).join('.');
@@ -1321,7 +1304,7 @@ export class Deparser implements DeparserVisitor {
1321
1304
  }
1322
1305
  return `${timestamp} AT TIME ZONE ${timezone}`;
1323
1306
  }
1324
- const params: string[] = [];
1307
+ const params = [];
1325
1308
  if (node.agg_star) {
1326
1309
  if (node.agg_distinct) {
1327
1310
  params.push('DISTINCT *');
@@ -1374,7 +1357,7 @@ export class Deparser implements DeparserVisitor {
1374
1357
  result += ` OVER ${node.over.name}`;
1375
1358
  }
1376
1359
  else {
1377
- const windowParts: string[] = [];
1360
+ const windowParts = [];
1378
1361
  if (node.over.partitionClause) {
1379
1362
  const partitions = ListUtils.unwrapList(node.over.partitionClause);
1380
1363
  const partitionStrs = partitions.map(p => this.visit(p, context));
@@ -1406,13 +1389,13 @@ export class Deparser implements DeparserVisitor {
1406
1389
  }
1407
1390
  return result;
1408
1391
  }
1409
- FuncExpr(node: any, context: DeparserContext): string {
1392
+ FuncExpr(node, context) {
1410
1393
  const funcName = `func_${node.funcid}`;
1411
1394
  const args = node.args ? ListUtils.unwrapList(node.args).map(arg => this.visit(arg, context)).join(', ') : '';
1412
1395
  return `${funcName}(${args})`;
1413
1396
  }
1414
- A_Const(node: any, context: DeparserContext): string {
1415
- const nodeAny = node as any;
1397
+ A_Const(node, context) {
1398
+ const nodeAny = node;
1416
1399
  if (nodeAny.ival !== undefined) {
1417
1400
  if (typeof nodeAny.ival === 'object' && nodeAny.ival !== null) {
1418
1401
  if (nodeAny.ival.ival !== undefined) {
@@ -1577,7 +1560,7 @@ export class Deparser implements DeparserVisitor {
1577
1560
  }
1578
1561
  return 'NULL';
1579
1562
  }
1580
- ColumnRef(node: any, context: DeparserContext): string {
1563
+ ColumnRef(node, context) {
1581
1564
  const fields = ListUtils.unwrapList(node.fields);
1582
1565
  return fields.map(field => {
1583
1566
  if (field.String) {
@@ -1589,16 +1572,16 @@ export class Deparser implements DeparserVisitor {
1589
1572
  return this.visit(field, context);
1590
1573
  }).join('.');
1591
1574
  }
1592
- TypeName(node: any, context: DeparserContext): string {
1575
+ TypeName(node, context) {
1593
1576
  if (!node.names) {
1594
1577
  return '';
1595
1578
  }
1596
- const output: string[] = [];
1579
+ const output = [];
1597
1580
  // Handle SETOF keyword
1598
1581
  if (node.setof) {
1599
1582
  output.push('SETOF');
1600
1583
  }
1601
- const names = node.names.map((name: any) => {
1584
+ const names = node.names.map((name) => {
1602
1585
  if (name.String) {
1603
1586
  return name.String.sval || name.String.str;
1604
1587
  }
@@ -1607,9 +1590,9 @@ export class Deparser implements DeparserVisitor {
1607
1590
  if (names.length === 0) {
1608
1591
  return '';
1609
1592
  }
1610
- let args: string | null = null;
1593
+ let args = null;
1611
1594
  if (node.typmods) {
1612
- const isInterval = names.some((name: any) => {
1595
+ const isInterval = names.some((name) => {
1613
1596
  const nameStr = typeof name === 'string' ? name : (name.String?.sval || name.String?.str);
1614
1597
  return nameStr === 'interval';
1615
1598
  });
@@ -1624,7 +1607,7 @@ export class Deparser implements DeparserVisitor {
1624
1607
  else if (node.typemod && node.typemod !== -1) {
1625
1608
  args = this.formatSingleTypeMod(node.typemod, names[0]);
1626
1609
  }
1627
- const mods = (name: string, size: string | null) => {
1610
+ const mods = (name, size) => {
1628
1611
  if (size != null) {
1629
1612
  // For interval types, use space separation for fields in all contexts
1630
1613
  if (name === 'interval') {
@@ -1639,7 +1622,7 @@ export class Deparser implements DeparserVisitor {
1639
1622
  }
1640
1623
  return name;
1641
1624
  };
1642
- const formatArrayBounds = (arrayBounds: any[]): string => {
1625
+ const formatArrayBounds = (arrayBounds) => {
1643
1626
  return arrayBounds.map(bound => {
1644
1627
  if (bound.Integer && bound.Integer.ival !== undefined && bound.Integer.ival !== -1) {
1645
1628
  return `[${bound.Integer.ival}]`;
@@ -1755,7 +1738,7 @@ export class Deparser implements DeparserVisitor {
1755
1738
  return output.join(' ');
1756
1739
  }
1757
1740
  }
1758
- const quotedNames = names.map((name: string) => QuoteUtils.quote(name));
1741
+ const quotedNames = names.map((name) => QuoteUtils.quote(name));
1759
1742
  let result = mods(quotedNames.join('.'), args);
1760
1743
  if (node.arrayBounds && node.arrayBounds.length > 0) {
1761
1744
  result += formatArrayBounds(node.arrayBounds);
@@ -1763,9 +1746,9 @@ export class Deparser implements DeparserVisitor {
1763
1746
  output.push(result);
1764
1747
  return output.join(' ');
1765
1748
  }
1766
- Alias(node: any, context: DeparserContext): string {
1749
+ Alias(node, context) {
1767
1750
  const name = node.aliasname;
1768
- const output: string[] = [];
1751
+ const output = [];
1769
1752
  if (node.colnames) {
1770
1753
  const colnames = ListUtils.unwrapList(node.colnames);
1771
1754
  const quotedColnames = colnames.map(col => {
@@ -1783,8 +1766,8 @@ export class Deparser implements DeparserVisitor {
1783
1766
  }
1784
1767
  return output.join(' ');
1785
1768
  }
1786
- RangeVar(node: any, context: DeparserContext): string {
1787
- const output: string[] = [];
1769
+ RangeVar(node, context) {
1770
+ const output = [];
1788
1771
  // Handle ONLY keyword for inheritance control (but not for type definitions, ALTER TYPE, or CREATE FOREIGN TABLE)
1789
1772
  if (node && (!('inh' in node) || node.inh === undefined) &&
1790
1773
  !context.parentNodeTypes.includes('CompositeTypeStmt') &&
@@ -1814,14 +1797,12 @@ export class Deparser implements DeparserVisitor {
1814
1797
  const result = output.join(' ');
1815
1798
  return result;
1816
1799
  }
1817
- formatIntervalTypeMods(typmods: any, context: DeparserContext): string | null {
1800
+ formatIntervalTypeMods(typmods, context) {
1818
1801
  if (!typmods || typmods.length === 0) {
1819
1802
  return null;
1820
1803
  }
1821
1804
  const mods = ListUtils.unwrapList(typmods);
1822
- const intervalFields: {
1823
- [key: number]: string;
1824
- } = {
1805
+ const intervalFields = {
1825
1806
  4: 'year',
1826
1807
  2: 'month',
1827
1808
  8: 'day',
@@ -1840,7 +1821,7 @@ export class Deparser implements DeparserVisitor {
1840
1821
  if (mods.length === 1) {
1841
1822
  const mod = mods[0];
1842
1823
  if (mod && typeof mod === 'object') {
1843
- const aConst = (mod as any).A_Const;
1824
+ const aConst = mod.A_Const;
1844
1825
  if (aConst && aConst.ival !== undefined) {
1845
1826
  const ivalValue = typeof aConst.ival === 'object' ? aConst.ival.ival : aConst.ival;
1846
1827
  if (ivalValue !== undefined) {
@@ -1858,12 +1839,12 @@ export class Deparser implements DeparserVisitor {
1858
1839
  const firstMod = mods[0];
1859
1840
  const secondMod = mods[1];
1860
1841
  if (firstMod && typeof firstMod === 'object') {
1861
- const firstConst = (firstMod as any).A_Const;
1842
+ const firstConst = firstMod.A_Const;
1862
1843
  if (firstConst && firstConst.ival !== undefined) {
1863
1844
  const firstValue = typeof firstConst.ival === 'object' ? firstConst.ival.ival : firstConst.ival;
1864
1845
  // Check if second mod is precision (empty ival object or specific precision value)
1865
1846
  if (secondMod && typeof secondMod === 'object') {
1866
- const secondConst = (secondMod as any).A_Const;
1847
+ const secondConst = secondMod.A_Const;
1867
1848
  if (secondConst && secondConst.ival !== undefined) {
1868
1849
  const secondValue = typeof secondConst.ival === 'object' ?
1869
1850
  (secondConst.ival.ival !== undefined ? secondConst.ival.ival : 0) :
@@ -1881,7 +1862,7 @@ export class Deparser implements DeparserVisitor {
1881
1862
  }
1882
1863
  const fieldSpecs = mods.map(mod => {
1883
1864
  if (mod && typeof mod === 'object') {
1884
- const aConst = (mod as any).A_Const;
1865
+ const aConst = mod.A_Const;
1885
1866
  if (aConst && aConst.ival !== undefined) {
1886
1867
  const ivalValue = typeof aConst.ival === 'object' ? aConst.ival.ival : aConst.ival;
1887
1868
  if (ivalValue !== undefined) {
@@ -1894,14 +1875,14 @@ export class Deparser implements DeparserVisitor {
1894
1875
  }).filter(Boolean);
1895
1876
  return fieldSpecs.length > 0 ? fieldSpecs.join(' ') : null;
1896
1877
  }
1897
- formatTypeMods(typmods: any, context: DeparserContext): string | null {
1878
+ formatTypeMods(typmods, context) {
1898
1879
  if (!typmods || typmods.length === 0) {
1899
1880
  return null;
1900
1881
  }
1901
1882
  const mods = ListUtils.unwrapList(typmods);
1902
1883
  const filteredMods = mods.filter(mod => {
1903
1884
  if (mod && typeof mod === 'object') {
1904
- const aConst = (mod as any).A_Const;
1885
+ const aConst = mod.A_Const;
1905
1886
  if (aConst && aConst.ival) {
1906
1887
  // Handle both direct number and nested object structures
1907
1888
  const ivalValue = typeof aConst.ival === 'object' ? aConst.ival.ival : aConst.ival;
@@ -1919,7 +1900,7 @@ export class Deparser implements DeparserVisitor {
1919
1900
  return this.deparse(mod, context);
1920
1901
  }).join(', ');
1921
1902
  }
1922
- formatSingleTypeMod(typemod: number, typeName: string): string | null {
1903
+ formatSingleTypeMod(typemod, typeName) {
1923
1904
  switch (typeName) {
1924
1905
  case 'varchar':
1925
1906
  case 'bpchar':
@@ -1954,7 +1935,7 @@ export class Deparser implements DeparserVisitor {
1954
1935
  }
1955
1936
  return null;
1956
1937
  }
1957
- getPgCatalogTypeName(typeName: string, size: string | null): string {
1938
+ getPgCatalogTypeName(typeName, size) {
1958
1939
  switch (typeName) {
1959
1940
  case 'bpchar':
1960
1941
  if (size != null) {
@@ -1987,7 +1968,7 @@ export class Deparser implements DeparserVisitor {
1987
1968
  return `pg_catalog.${typeName}`;
1988
1969
  }
1989
1970
  }
1990
- isPgCatalogType(typeName: string): boolean {
1971
+ isPgCatalogType(typeName) {
1991
1972
  const cleanTypeName = typeName.replace(/^pg_catalog\./, '');
1992
1973
  if (pgCatalogTypes.includes(cleanTypeName)) {
1993
1974
  return true;
@@ -1999,13 +1980,13 @@ export class Deparser implements DeparserVisitor {
1999
1980
  }
2000
1981
  return false;
2001
1982
  }
2002
- A_ArrayExpr(node: any, context: DeparserContext): string {
1983
+ A_ArrayExpr(node, context) {
2003
1984
  const elements = ListUtils.unwrapList(node.elements);
2004
1985
  const elementStrs = elements.map(el => this.visit(el, context));
2005
1986
  return `ARRAY[${elementStrs.join(', ')}]`;
2006
1987
  }
2007
- A_Indices(node: any, context: DeparserContext): string {
2008
- const output: string[] = [];
1988
+ A_Indices(node, context) {
1989
+ const output = [];
2009
1990
  if (node.is_slice) {
2010
1991
  if (node.lidx) {
2011
1992
  output.push(this.visit(node.lidx, context));
@@ -2022,7 +2003,7 @@ export class Deparser implements DeparserVisitor {
2022
2003
  }
2023
2004
  return `[${output.join('')}]`;
2024
2005
  }
2025
- A_Indirection(node: any, context: DeparserContext): string {
2006
+ A_Indirection(node, context) {
2026
2007
  let argStr = this.visit(node.arg, context);
2027
2008
  const argType = this.getNodeType(node.arg);
2028
2009
  if (argType === 'TypeCast' || argType === 'SubLink' || argType === 'A_Expr' || argType === 'FuncCall' || argType === 'A_Indirection' || argType === 'ColumnRef' || argType === 'RowExpr') {
@@ -2041,11 +2022,11 @@ export class Deparser implements DeparserVisitor {
2041
2022
  }
2042
2023
  return output.join('');
2043
2024
  }
2044
- A_Star(node: any, context: DeparserContext): string {
2025
+ A_Star(node, context) {
2045
2026
  return '*';
2046
2027
  }
2047
- CaseExpr(node: any, context: DeparserContext): string {
2048
- const output: string[] = ['CASE'];
2028
+ CaseExpr(node, context) {
2029
+ const output = ['CASE'];
2049
2030
  if (node.arg) {
2050
2031
  output.push(this.visit(node.arg, context));
2051
2032
  }
@@ -2084,20 +2065,20 @@ export class Deparser implements DeparserVisitor {
2084
2065
  return output.join(' ');
2085
2066
  }
2086
2067
  }
2087
- CoalesceExpr(node: any, context: DeparserContext): string {
2068
+ CoalesceExpr(node, context) {
2088
2069
  const args = ListUtils.unwrapList(node.args);
2089
2070
  const argStrs = args.map(arg => this.visit(arg, context));
2090
2071
  return `COALESCE(${argStrs.join(', ')})`;
2091
2072
  }
2092
- TypeCast(node: any, context: DeparserContext): string {
2073
+ TypeCast(node, context) {
2093
2074
  const arg = this.visit(node.arg, context);
2094
2075
  const typeName = this.TypeName(node.typeName, context);
2095
2076
  // Check if this is a bpchar typecast that should preserve original syntax for AST consistency
2096
2077
  if (typeName === 'bpchar' || typeName === 'pg_catalog.bpchar') {
2097
2078
  const names = node.typeName?.names;
2098
2079
  const isQualifiedBpchar = names && names.length === 2 &&
2099
- (names[0] as any)?.String?.sval === 'pg_catalog' &&
2100
- (names[1] as any)?.String?.sval === 'bpchar';
2080
+ names[0]?.String?.sval === 'pg_catalog' &&
2081
+ names[1]?.String?.sval === 'bpchar';
2101
2082
  if (isQualifiedBpchar) {
2102
2083
  return `CAST(${arg} AS ${typeName})`;
2103
2084
  }
@@ -2118,8 +2099,8 @@ export class Deparser implements DeparserVisitor {
2118
2099
  }
2119
2100
  return `CAST(${arg} AS ${typeName})`;
2120
2101
  }
2121
- CollateClause(node: any, context: DeparserContext): string {
2122
- const output: string[] = [];
2102
+ CollateClause(node, context) {
2103
+ const output = [];
2123
2104
  if (node.arg) {
2124
2105
  let argStr = this.visit(node.arg, context);
2125
2106
  const argType = this.getNodeType(node.arg);
@@ -2135,11 +2116,11 @@ export class Deparser implements DeparserVisitor {
2135
2116
  }
2136
2117
  return output.join(' ');
2137
2118
  }
2138
- BooleanTest(node: any, context: DeparserContext): string {
2139
- const output: string[] = [];
2119
+ BooleanTest(node, context) {
2120
+ const output = [];
2140
2121
  const boolContext = context.spawn('BooleanTest', { bool: true });
2141
2122
  output.push(this.visit(node.arg, boolContext));
2142
- switch (node.booltesttype as string) {
2123
+ switch (node.booltesttype) {
2143
2124
  case 'IS_TRUE':
2144
2125
  output.push('IS TRUE');
2145
2126
  break;
@@ -2161,10 +2142,10 @@ export class Deparser implements DeparserVisitor {
2161
2142
  }
2162
2143
  return output.join(' ');
2163
2144
  }
2164
- NullTest(node: any, context: DeparserContext): string {
2165
- const output: string[] = [];
2145
+ NullTest(node, context) {
2146
+ const output = [];
2166
2147
  output.push(this.visit(node.arg, context));
2167
- switch (node.nulltesttype as string) {
2148
+ switch (node.nulltesttype) {
2168
2149
  case 'IS_NULL':
2169
2150
  output.push('IS NULL');
2170
2151
  break;
@@ -2174,7 +2155,7 @@ export class Deparser implements DeparserVisitor {
2174
2155
  }
2175
2156
  return output.join(' ');
2176
2157
  }
2177
- private static readonly RESERVED_WORDS = new Set([
2158
+ static RESERVED_WORDS = new Set([
2178
2159
  'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc', 'asymmetric', 'both',
2179
2160
  'case', 'cast', 'check', 'collate', 'column', 'constraint', 'create', 'current_catalog',
2180
2161
  'current_date', 'current_role', 'current_time', 'current_timestamp', 'current_user',
@@ -2186,7 +2167,7 @@ export class Deparser implements DeparserVisitor {
2186
2167
  'then', 'to', 'trailing', 'true', 'union', 'unique', 'user', 'using', 'variadic',
2187
2168
  'when', 'where', 'window', 'with'
2188
2169
  ]);
2189
- private static needsQuotes(value: string): boolean {
2170
+ static needsQuotes(value) {
2190
2171
  if (!value)
2191
2172
  return false;
2192
2173
  const needsQuotesRegex = /[a-z]+[\W\w]*[A-Z]+|[A-Z]+[\W\w]*[a-z]+|\W/;
@@ -2195,16 +2176,14 @@ export class Deparser implements DeparserVisitor {
2195
2176
  Deparser.RESERVED_WORDS.has(value.toLowerCase()) ||
2196
2177
  isAllUppercase;
2197
2178
  }
2198
- quoteIfNeeded(value: string): string {
2179
+ quoteIfNeeded(value) {
2199
2180
  if (Deparser.needsQuotes(value)) {
2200
2181
  return `"${value}"`;
2201
2182
  }
2202
2183
  return value;
2203
2184
  }
2204
- preserveOperatorDefElemCase(defName: string): string {
2205
- const caseMap: {
2206
- [key: string]: string;
2207
- } = {
2185
+ preserveOperatorDefElemCase(defName) {
2186
+ const caseMap = {
2208
2187
  'leftarg': 'Leftarg',
2209
2188
  'rightarg': 'Rightarg',
2210
2189
  'procedure': 'Procedure',
@@ -2218,7 +2197,7 @@ export class Deparser implements DeparserVisitor {
2218
2197
  };
2219
2198
  return caseMap[defName.toLowerCase()] || defName;
2220
2199
  }
2221
- String(node: any, context: DeparserContext): string {
2200
+ String(node, context) {
2222
2201
  if (context.isStringLiteral || context.isEnumValue) {
2223
2202
  return QuoteUtils.formatEString(node.sval || '');
2224
2203
  }
@@ -2236,16 +2215,16 @@ export class Deparser implements DeparserVisitor {
2236
2215
  }
2237
2216
  return Deparser.needsQuotes(value) ? `"${value}"` : value;
2238
2217
  }
2239
- Integer(node: any, context: DeparserContext): string {
2218
+ Integer(node, context) {
2240
2219
  return node.ival?.toString() || '0';
2241
2220
  }
2242
- Float(node: any, context: DeparserContext): string {
2221
+ Float(node, context) {
2243
2222
  return node.fval || '0.0';
2244
2223
  }
2245
- Boolean(node: any, context: DeparserContext): string {
2224
+ Boolean(node, context) {
2246
2225
  return node.boolval ? 'true' : 'false';
2247
2226
  }
2248
- BitString(node: any, context: DeparserContext): string {
2227
+ BitString(node, context) {
2249
2228
  // Check if this is a hexadecimal bit string (starts with x)
2250
2229
  if (node.bsval.startsWith('x')) {
2251
2230
  return `x'${node.bsval.substring(1)}'`;
@@ -2256,17 +2235,17 @@ export class Deparser implements DeparserVisitor {
2256
2235
  // Fallback for raw values without prefix
2257
2236
  return `b'${node.bsval}'`;
2258
2237
  }
2259
- Null(node: any, context: DeparserContext): string {
2238
+ Null(node, context) {
2260
2239
  return 'NULL';
2261
2240
  }
2262
- List(node: any, context: DeparserContext): string {
2241
+ List(node, context) {
2263
2242
  if (!node.items || node.items.length === 0) {
2264
2243
  return '';
2265
2244
  }
2266
- return node.items.map((item: any) => this.visit(item, context)).join(', ');
2245
+ return node.items.map((item) => this.visit(item, context)).join(', ');
2267
2246
  }
2268
- CreateStmt(node: any, context: DeparserContext): string {
2269
- const output: string[] = ['CREATE'];
2247
+ CreateStmt(node, context) {
2248
+ const output = ['CREATE'];
2270
2249
  if (node.relation && node.relation.relpersistence === 't') {
2271
2250
  output.push('TEMPORARY');
2272
2251
  }
@@ -2396,7 +2375,7 @@ export class Deparser implements DeparserVisitor {
2396
2375
  // Handle table options like WITH (fillfactor=10)
2397
2376
  if (node.options && node.options.length > 0) {
2398
2377
  const createStmtContext = context.spawn('CreateStmt');
2399
- const optionStrs = node.options.map((option: any) => {
2378
+ const optionStrs = node.options.map((option) => {
2400
2379
  return this.deparse(option, createStmtContext);
2401
2380
  });
2402
2381
  output.push('WITH', `(${optionStrs.join(', ')})`);
@@ -2408,8 +2387,8 @@ export class Deparser implements DeparserVisitor {
2408
2387
  }
2409
2388
  return output.join(' ');
2410
2389
  }
2411
- ColumnDef(node: any, context: DeparserContext): string {
2412
- const output: string[] = [];
2390
+ ColumnDef(node, context) {
2391
+ const output = [];
2413
2392
  if (node.colname) {
2414
2393
  output.push(QuoteUtils.quote(node.colname));
2415
2394
  }
@@ -2447,8 +2426,8 @@ export class Deparser implements DeparserVisitor {
2447
2426
  }
2448
2427
  return output.join(' ');
2449
2428
  }
2450
- Constraint(node: any, context: DeparserContext): string {
2451
- const output: string[] = [];
2429
+ Constraint(node, context) {
2430
+ const output = [];
2452
2431
  // Handle constraint name if present
2453
2432
  if (node.conname && (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_UNIQUE' || node.contype === 'CONSTR_PRIMARY' || node.contype === 'CONSTR_FOREIGN')) {
2454
2433
  output.push('CONSTRAINT');
@@ -2845,7 +2824,7 @@ export class Deparser implements DeparserVisitor {
2845
2824
  }
2846
2825
  return output.join(' ');
2847
2826
  }
2848
- SubLink(node: any, context: DeparserContext): string {
2827
+ SubLink(node, context) {
2849
2828
  const subselect = context.parens(this.visit(node.subselect, context));
2850
2829
  switch (node.subLinkType) {
2851
2830
  case 'ANY_SUBLINK':
@@ -2875,8 +2854,8 @@ export class Deparser implements DeparserVisitor {
2875
2854
  return subselect;
2876
2855
  }
2877
2856
  }
2878
- CaseWhen(node: any, context: DeparserContext): string {
2879
- const output: string[] = ['WHEN'];
2857
+ CaseWhen(node, context) {
2858
+ const output = ['WHEN'];
2880
2859
  if (node.expr) {
2881
2860
  output.push(this.visit(node.expr, context));
2882
2861
  }
@@ -2886,12 +2865,12 @@ export class Deparser implements DeparserVisitor {
2886
2865
  }
2887
2866
  return output.join(' ');
2888
2867
  }
2889
- WindowDef(node: any, context: DeparserContext): string {
2890
- const output: string[] = [];
2868
+ WindowDef(node, context) {
2869
+ const output = [];
2891
2870
  if (node.name) {
2892
2871
  output.push(node.name);
2893
2872
  }
2894
- const windowParts: string[] = [];
2873
+ const windowParts = [];
2895
2874
  if (node.partitionClause) {
2896
2875
  const partitions = ListUtils.unwrapList(node.partitionClause);
2897
2876
  const partitionStrs = partitions.map(p => this.visit(p, context));
@@ -2924,11 +2903,11 @@ export class Deparser implements DeparserVisitor {
2924
2903
  }
2925
2904
  return output.join(' ');
2926
2905
  }
2927
- formatWindowFrame(node: any, context: DeparserContext): string | null {
2906
+ formatWindowFrame(node, context) {
2928
2907
  if (!node.frameOptions)
2929
2908
  return null;
2930
2909
  const frameOptions = node.frameOptions;
2931
- const frameParts: string[] = [];
2910
+ const frameParts = [];
2932
2911
  if (frameOptions & 0x01) { // FRAMEOPTION_NONDEFAULT
2933
2912
  if (frameOptions & 0x02) { // FRAMEOPTION_RANGE
2934
2913
  frameParts.push('RANGE');
@@ -2942,7 +2921,7 @@ export class Deparser implements DeparserVisitor {
2942
2921
  }
2943
2922
  if (frameParts.length === 0)
2944
2923
  return null;
2945
- const boundsParts: string[] = [];
2924
+ const boundsParts = [];
2946
2925
  // Handle specific frameOptions values that have known mappings
2947
2926
  if (frameOptions === 789) {
2948
2927
  boundsParts.push('CURRENT ROW');
@@ -3024,8 +3003,8 @@ export class Deparser implements DeparserVisitor {
3024
3003
  }
3025
3004
  return frameParts.join(' ');
3026
3005
  }
3027
- SortBy(node: any, context: DeparserContext): string {
3028
- const output: string[] = [];
3006
+ SortBy(node, context) {
3007
+ const output = [];
3029
3008
  if (node.node) {
3030
3009
  output.push(this.visit(node.node, context));
3031
3010
  }
@@ -3053,7 +3032,7 @@ export class Deparser implements DeparserVisitor {
3053
3032
  }
3054
3033
  return output.join(' ');
3055
3034
  }
3056
- GroupingSet(node: any, context: DeparserContext): string {
3035
+ GroupingSet(node, context) {
3057
3036
  switch (node.kind) {
3058
3037
  case 'GROUPING_SET_EMPTY':
3059
3038
  return '()';
@@ -3076,8 +3055,8 @@ export class Deparser implements DeparserVisitor {
3076
3055
  return '';
3077
3056
  }
3078
3057
  }
3079
- CommonTableExpr(node: any, context: DeparserContext): string {
3080
- const output: string[] = [];
3058
+ CommonTableExpr(node, context) {
3059
+ const output = [];
3081
3060
  if (node.ctename) {
3082
3061
  output.push(node.ctename);
3083
3062
  }
@@ -3100,11 +3079,11 @@ export class Deparser implements DeparserVisitor {
3100
3079
  }
3101
3080
  return output.join(' ');
3102
3081
  }
3103
- ParamRef(node: any, context: DeparserContext): string {
3082
+ ParamRef(node, context) {
3104
3083
  return `$${node.number}`;
3105
3084
  }
3106
- LockingClause(node: any, context: DeparserContext): string {
3107
- const output: string[] = [];
3085
+ LockingClause(node, context) {
3086
+ const output = [];
3108
3087
  switch (node.strength) {
3109
3088
  case 'LCS_FORUPDATE':
3110
3089
  output.push('FOR UPDATE');
@@ -3136,7 +3115,7 @@ export class Deparser implements DeparserVisitor {
3136
3115
  }
3137
3116
  return output.join(' ');
3138
3117
  }
3139
- MinMaxExpr(node: any, context: DeparserContext): string {
3118
+ MinMaxExpr(node, context) {
3140
3119
  const args = ListUtils.unwrapList(node.args);
3141
3120
  const argStrs = args.map(arg => this.visit(arg, context));
3142
3121
  if (node.op === 'IS_GREATEST') {
@@ -3146,7 +3125,7 @@ export class Deparser implements DeparserVisitor {
3146
3125
  return `LEAST(${argStrs.join(', ')})`;
3147
3126
  }
3148
3127
  }
3149
- RowExpr(node: any, context: DeparserContext): string {
3128
+ RowExpr(node, context) {
3150
3129
  const args = ListUtils.unwrapList(node.args);
3151
3130
  const argStrs = args.map(arg => this.visit(arg, context));
3152
3131
  if (node.row_format === 'COERCE_IMPLICIT_CAST') {
@@ -3154,7 +3133,7 @@ export class Deparser implements DeparserVisitor {
3154
3133
  }
3155
3134
  return `ROW(${argStrs.join(', ')})`;
3156
3135
  }
3157
- OpExpr(node: any, context: DeparserContext): string {
3136
+ OpExpr(node, context) {
3158
3137
  const args = ListUtils.unwrapList(node.args);
3159
3138
  if (args.length === 2) {
3160
3139
  const left = this.visit(args[0], context);
@@ -3169,7 +3148,7 @@ export class Deparser implements DeparserVisitor {
3169
3148
  }
3170
3149
  throw new Error(`Unsupported OpExpr with ${args.length} arguments`);
3171
3150
  }
3172
- DistinctExpr(node: any, context: DeparserContext): string {
3151
+ DistinctExpr(node, context) {
3173
3152
  const args = ListUtils.unwrapList(node.args);
3174
3153
  if (args.length === 2) {
3175
3154
  const literalContext = context.spawn('DistinctExpr', { isStringLiteral: true });
@@ -3179,7 +3158,7 @@ export class Deparser implements DeparserVisitor {
3179
3158
  }
3180
3159
  throw new Error(`DistinctExpr requires exactly 2 arguments, got ${args.length}`);
3181
3160
  }
3182
- NullIfExpr(node: any, context: DeparserContext): string {
3161
+ NullIfExpr(node, context) {
3183
3162
  const args = ListUtils.unwrapList(node.args);
3184
3163
  if (args.length === 2) {
3185
3164
  const literalContext = context.spawn('NullIfExpr', { isStringLiteral: true });
@@ -3189,7 +3168,7 @@ export class Deparser implements DeparserVisitor {
3189
3168
  }
3190
3169
  throw new Error(`NullIfExpr requires exactly 2 arguments, got ${args.length}`);
3191
3170
  }
3192
- ScalarArrayOpExpr(node: any, context: DeparserContext): string {
3171
+ ScalarArrayOpExpr(node, context) {
3193
3172
  const args = ListUtils.unwrapList(node.args);
3194
3173
  if (args.length === 2) {
3195
3174
  const left = this.visit(args[0], context);
@@ -3200,7 +3179,7 @@ export class Deparser implements DeparserVisitor {
3200
3179
  }
3201
3180
  throw new Error(`ScalarArrayOpExpr requires exactly 2 arguments, got ${args.length}`);
3202
3181
  }
3203
- Aggref(node: any, context: DeparserContext): string {
3182
+ Aggref(node, context) {
3204
3183
  const funcName = this.getAggFunctionName(node.aggfnoid);
3205
3184
  let result = funcName + '(';
3206
3185
  const hasDistinct = node.aggdistinct && node.aggdistinct.length > 0;
@@ -3231,7 +3210,7 @@ export class Deparser implements DeparserVisitor {
3231
3210
  }
3232
3211
  return result;
3233
3212
  }
3234
- WindowFunc(node: any, context: DeparserContext): string {
3213
+ WindowFunc(node, context) {
3235
3214
  const funcName = this.getWindowFunctionName(node.winfnoid);
3236
3215
  let result = funcName + '(';
3237
3216
  if (node.args && node.args.length > 0) {
@@ -3241,7 +3220,7 @@ export class Deparser implements DeparserVisitor {
3241
3220
  }
3242
3221
  result += ') OVER (';
3243
3222
  if (node.winref && typeof node.winref === 'object') {
3244
- result += this.visit(node.winref as any, context);
3223
+ result += this.visit(node.winref, context);
3245
3224
  }
3246
3225
  else if (node.winref) {
3247
3226
  result += 'ORDER BY created_at ASC';
@@ -3249,8 +3228,8 @@ export class Deparser implements DeparserVisitor {
3249
3228
  result += ')';
3250
3229
  return result;
3251
3230
  }
3252
- FieldSelect(node: any, context: DeparserContext): string {
3253
- const output: string[] = [];
3231
+ FieldSelect(node, context) {
3232
+ const output = [];
3254
3233
  if (node.arg) {
3255
3234
  output.push(this.visit(node.arg, context));
3256
3235
  }
@@ -3259,34 +3238,34 @@ export class Deparser implements DeparserVisitor {
3259
3238
  }
3260
3239
  return output.join('');
3261
3240
  }
3262
- RelabelType(node: any, context: DeparserContext): string {
3241
+ RelabelType(node, context) {
3263
3242
  if (node.arg) {
3264
3243
  const literalContext = context.spawn('RelabelType', { isStringLiteral: true });
3265
3244
  return this.visit(node.arg, literalContext);
3266
3245
  }
3267
3246
  return '';
3268
3247
  }
3269
- CoerceViaIO(node: any, context: DeparserContext): string {
3248
+ CoerceViaIO(node, context) {
3270
3249
  if (node.arg) {
3271
3250
  return this.visit(node.arg, context);
3272
3251
  }
3273
3252
  return '';
3274
3253
  }
3275
- ArrayCoerceExpr(node: any, context: DeparserContext): string {
3254
+ ArrayCoerceExpr(node, context) {
3276
3255
  if (node.arg) {
3277
3256
  return this.visit(node.arg, context);
3278
3257
  }
3279
3258
  return '';
3280
3259
  }
3281
- ConvertRowtypeExpr(node: any, context: DeparserContext): string {
3260
+ ConvertRowtypeExpr(node, context) {
3282
3261
  if (node.arg) {
3283
3262
  const literalContext = context.spawn('ConvertRowtypeExpr', { isStringLiteral: true });
3284
3263
  return this.visit(node.arg, literalContext);
3285
3264
  }
3286
3265
  return '';
3287
3266
  }
3288
- NamedArgExpr(node: any, context: DeparserContext): string {
3289
- const output: string[] = [];
3267
+ NamedArgExpr(node, context) {
3268
+ const output = [];
3290
3269
  if (node.name) {
3291
3270
  output.push(node.name);
3292
3271
  output.push('=>');
@@ -3296,8 +3275,8 @@ export class Deparser implements DeparserVisitor {
3296
3275
  }
3297
3276
  return output.join(' ');
3298
3277
  }
3299
- ViewStmt(node: any, context: DeparserContext): string {
3300
- const output: string[] = [];
3278
+ ViewStmt(node, context) {
3279
+ const output = [];
3301
3280
  output.push('CREATE');
3302
3281
  if (node.replace) {
3303
3282
  output.push('OR REPLACE');
@@ -3335,8 +3314,8 @@ export class Deparser implements DeparserVisitor {
3335
3314
  }
3336
3315
  return output.join(' ');
3337
3316
  }
3338
- IndexStmt(node: any, context: DeparserContext): string {
3339
- const output: string[] = [];
3317
+ IndexStmt(node, context) {
3318
+ const output = [];
3340
3319
  output.push('CREATE');
3341
3320
  if (node.unique) {
3342
3321
  output.push('UNIQUE');
@@ -3387,8 +3366,8 @@ export class Deparser implements DeparserVisitor {
3387
3366
  }
3388
3367
  return output.join(' ');
3389
3368
  }
3390
- IndexElem(node: any, context: DeparserContext): string {
3391
- const output: string[] = [];
3369
+ IndexElem(node, context) {
3370
+ const output = [];
3392
3371
  if (node.name) {
3393
3372
  output.push(QuoteUtils.quote(node.name));
3394
3373
  }
@@ -3438,8 +3417,8 @@ export class Deparser implements DeparserVisitor {
3438
3417
  }
3439
3418
  return output.join(' ');
3440
3419
  }
3441
- PartitionElem(node: any, context: DeparserContext): string {
3442
- const output: string[] = [];
3420
+ PartitionElem(node, context) {
3421
+ const output = [];
3443
3422
  if (node.name) {
3444
3423
  output.push(QuoteUtils.quote(node.name));
3445
3424
  }
@@ -3457,13 +3436,13 @@ export class Deparser implements DeparserVisitor {
3457
3436
  }
3458
3437
  return output.join(' ');
3459
3438
  }
3460
- PartitionCmd(node: any, context: DeparserContext): string {
3461
- const output: string[] = [];
3439
+ PartitionCmd(node, context) {
3440
+ const output = [];
3462
3441
  if (node.concurrent) {
3463
3442
  output.push('CONCURRENTLY');
3464
3443
  }
3465
3444
  if (node.name) {
3466
- output.push(this.visit(node.name as any, context));
3445
+ output.push(this.visit(node.name, context));
3467
3446
  }
3468
3447
  if (node.bound) {
3469
3448
  if (node.bound.strategy === 'l' && node.bound.listdatums) {
@@ -3499,10 +3478,8 @@ export class Deparser implements DeparserVisitor {
3499
3478
  }
3500
3479
  return output.join(' ');
3501
3480
  }
3502
- private getAggFunctionName(aggfnoid?: number): string {
3503
- const commonAggFunctions: {
3504
- [key: number]: string;
3505
- } = {
3481
+ getAggFunctionName(aggfnoid) {
3482
+ const commonAggFunctions = {
3506
3483
  2100: 'avg',
3507
3484
  2101: 'count',
3508
3485
  2102: 'max',
@@ -3515,10 +3492,8 @@ export class Deparser implements DeparserVisitor {
3515
3492
  };
3516
3493
  return commonAggFunctions[aggfnoid || 0] || 'unknown_agg';
3517
3494
  }
3518
- private getWindowFunctionName(winfnoid?: number): string {
3519
- const commonWindowFunctions: {
3520
- [key: number]: string;
3521
- } = {
3495
+ getWindowFunctionName(winfnoid) {
3496
+ const commonWindowFunctions = {
3522
3497
  3100: 'row_number',
3523
3498
  3101: 'rank',
3524
3499
  3102: 'dense_rank',
@@ -3532,10 +3507,8 @@ export class Deparser implements DeparserVisitor {
3532
3507
  };
3533
3508
  return commonWindowFunctions[winfnoid || 0] || 'unknown_window_func';
3534
3509
  }
3535
- private getOperatorName(opno?: number): string {
3536
- const commonOperators: {
3537
- [key: number]: string;
3538
- } = {
3510
+ getOperatorName(opno) {
3511
+ const commonOperators = {
3539
3512
  96: '=',
3540
3513
  518: '<>',
3541
3514
  97: '<',
@@ -3560,8 +3533,8 @@ export class Deparser implements DeparserVisitor {
3560
3533
  };
3561
3534
  return commonOperators[opno || 0] || '=';
3562
3535
  }
3563
- JoinExpr(node: any, context: DeparserContext): string {
3564
- const output: string[] = [];
3536
+ JoinExpr(node, context) {
3537
+ const output = [];
3565
3538
  if (node.larg) {
3566
3539
  output.push(this.visit(node.larg, context));
3567
3540
  }
@@ -3670,7 +3643,7 @@ export class Deparser implements DeparserVisitor {
3670
3643
  }
3671
3644
  return result;
3672
3645
  }
3673
- FromExpr(node: any, context: DeparserContext): string {
3646
+ FromExpr(node, context) {
3674
3647
  const fromlist = ListUtils.unwrapList(node.fromlist);
3675
3648
  const fromStrs = fromlist.map(item => this.visit(item, context));
3676
3649
  let result = fromStrs.join(', ');
@@ -3679,8 +3652,8 @@ export class Deparser implements DeparserVisitor {
3679
3652
  }
3680
3653
  return result;
3681
3654
  }
3682
- TransactionStmt(node: any, context: DeparserContext): string {
3683
- const output: string[] = [];
3655
+ TransactionStmt(node, context) {
3656
+ const output = [];
3684
3657
  switch (node.kind) {
3685
3658
  case 'TRANS_STMT_BEGIN':
3686
3659
  output.push('BEGIN');
@@ -3790,7 +3763,7 @@ export class Deparser implements DeparserVisitor {
3790
3763
  }
3791
3764
  return output.join(' ');
3792
3765
  }
3793
- VariableSetStmt(node: any, context: DeparserContext): string {
3766
+ VariableSetStmt(node, context) {
3794
3767
  switch (node.kind) {
3795
3768
  case 'VAR_SET_VALUE':
3796
3769
  const localPrefix = node.is_local ? 'LOCAL ' : '';
@@ -3820,7 +3793,7 @@ export class Deparser implements DeparserVisitor {
3820
3793
  case 'VAR_SET_MULTI':
3821
3794
  if (node.name === 'TRANSACTION' || node.name === 'SESSION CHARACTERISTICS') {
3822
3795
  // Handle SET TRANSACTION statements specially
3823
- const transactionOptions: string[] = [];
3796
+ const transactionOptions = [];
3824
3797
  if (node.args) {
3825
3798
  const args = ListUtils.unwrapList(node.args);
3826
3799
  for (const arg of args) {
@@ -3897,14 +3870,14 @@ export class Deparser implements DeparserVisitor {
3897
3870
  throw new Error(`Unsupported VariableSetStmt kind: ${node.kind}`);
3898
3871
  }
3899
3872
  }
3900
- VariableShowStmt(node: any, context: DeparserContext): string {
3873
+ VariableShowStmt(node, context) {
3901
3874
  if (node.name === 'ALL') {
3902
3875
  return 'SHOW ALL';
3903
3876
  }
3904
3877
  return `SHOW ${node.name}`;
3905
3878
  }
3906
- CreateSchemaStmt(node: any, context: DeparserContext): string {
3907
- const output: string[] = ['CREATE SCHEMA'];
3879
+ CreateSchemaStmt(node, context) {
3880
+ const output = ['CREATE SCHEMA'];
3908
3881
  if (node.if_not_exists) {
3909
3882
  output.push('IF NOT EXISTS');
3910
3883
  }
@@ -3923,7 +3896,7 @@ export class Deparser implements DeparserVisitor {
3923
3896
  }
3924
3897
  return output.join(' ');
3925
3898
  }
3926
- RoleSpec(node: any, context: DeparserContext): string {
3899
+ RoleSpec(node, context) {
3927
3900
  if (node.rolename) {
3928
3901
  return this.quoteIfNeeded(node.rolename);
3929
3902
  }
@@ -3940,14 +3913,14 @@ export class Deparser implements DeparserVisitor {
3940
3913
  return 'PUBLIC';
3941
3914
  }
3942
3915
  }
3943
- roletype(node: any, context: DeparserContext): string {
3916
+ roletype(node, context) {
3944
3917
  if (node.rolename) {
3945
3918
  return node.rolename;
3946
3919
  }
3947
3920
  return '';
3948
3921
  }
3949
- DropStmt(node: any, context: DeparserContext): string {
3950
- const output: string[] = ['DROP'];
3922
+ DropStmt(node, context) {
3923
+ const output = ['DROP'];
3951
3924
  if (node.removeType) {
3952
3925
  switch (node.removeType) {
3953
3926
  case 'OBJECT_TABLE':
@@ -4113,8 +4086,8 @@ export class Deparser implements DeparserVisitor {
4113
4086
  if (node.objects && node.objects.length > 0) {
4114
4087
  if (node.removeType === 'OBJECT_POLICY') {
4115
4088
  const objList = node.objects[0];
4116
- if (objList && (objList as any).List && (objList as any).List.items) {
4117
- const items = (objList as any).List.items.map((item: any) => {
4089
+ if (objList && objList.List && objList.List.items) {
4090
+ const items = objList.List.items.map((item) => {
4118
4091
  if (item.String && item.String.sval) {
4119
4092
  return item.String.sval;
4120
4093
  }
@@ -4135,11 +4108,11 @@ export class Deparser implements DeparserVisitor {
4135
4108
  }
4136
4109
  }
4137
4110
  else if (node.removeType === 'OBJECT_CAST') {
4138
- const objects = node.objects.map((objList: any) => {
4111
+ const objects = node.objects.map((objList) => {
4139
4112
  if (objList && objList.List && objList.List.items) {
4140
- const items = objList.List.items.map((item: any) => {
4113
+ const items = objList.List.items.map((item) => {
4141
4114
  return this.visit(item, context);
4142
- }).filter((name: string) => name && name.trim());
4115
+ }).filter((name) => name && name.trim());
4143
4116
  if (items.length === 2) {
4144
4117
  const [sourceType, targetType] = items;
4145
4118
  return `(${sourceType} AS ${targetType})`;
@@ -4148,20 +4121,20 @@ export class Deparser implements DeparserVisitor {
4148
4121
  }
4149
4122
  const objName = this.visit(objList, context);
4150
4123
  return objName;
4151
- }).filter((name: string) => name && name.trim()).join(', ');
4124
+ }).filter((name) => name && name.trim()).join(', ');
4152
4125
  if (objects) {
4153
4126
  output.push(objects);
4154
4127
  }
4155
4128
  }
4156
4129
  else if (node.removeType === 'OBJECT_TRIGGER' || node.removeType === 'OBJECT_RULE') {
4157
- const objects = node.objects.map((objList: any) => {
4130
+ const objects = node.objects.map((objList) => {
4158
4131
  if (objList && objList.List && objList.List.items) {
4159
- const items = objList.List.items.map((item: any) => {
4132
+ const items = objList.List.items.map((item) => {
4160
4133
  if (item.String && item.String.sval) {
4161
4134
  return QuoteUtils.quote(item.String.sval);
4162
4135
  }
4163
4136
  return this.visit(item, context);
4164
- }).filter((name: string) => name && name.trim());
4137
+ }).filter((name) => name && name.trim());
4165
4138
  if (items.length === 2) {
4166
4139
  const [tableName, triggerName] = items;
4167
4140
  return `${triggerName} ON ${tableName}`;
@@ -4174,21 +4147,21 @@ export class Deparser implements DeparserVisitor {
4174
4147
  }
4175
4148
  const objName = this.visit(objList, context);
4176
4149
  return objName;
4177
- }).filter((name: string) => name && name.trim()).join(', ');
4150
+ }).filter((name) => name && name.trim()).join(', ');
4178
4151
  if (objects) {
4179
4152
  output.push(objects);
4180
4153
  }
4181
4154
  }
4182
4155
  else if (node.removeType === 'OBJECT_OPFAMILY' || node.removeType === 'OBJECT_OPCLASS') {
4183
4156
  // Handle operator family and operator class objects specially to format name USING access_method correctly
4184
- const objects = node.objects.map((objList: any) => {
4157
+ const objects = node.objects.map((objList) => {
4185
4158
  if (objList && objList.List && objList.List.items) {
4186
- const items = objList.List.items.map((item: any) => {
4159
+ const items = objList.List.items.map((item) => {
4187
4160
  if (item.String && item.String.sval) {
4188
4161
  return item.String.sval;
4189
4162
  }
4190
4163
  return this.visit(item, context);
4191
- }).filter((name: string) => name && name.trim());
4164
+ }).filter((name) => name && name.trim());
4192
4165
  if (items.length === 2) {
4193
4166
  const accessMethod = items[0];
4194
4167
  const objectName = items[1];
@@ -4204,21 +4177,21 @@ export class Deparser implements DeparserVisitor {
4204
4177
  }
4205
4178
  const objName = this.visit(objList, context);
4206
4179
  return objName;
4207
- }).filter((name: string) => name && name.trim()).join(', ');
4180
+ }).filter((name) => name && name.trim()).join(', ');
4208
4181
  if (objects) {
4209
4182
  output.push(objects);
4210
4183
  }
4211
4184
  }
4212
4185
  else if (node.removeType === 'OBJECT_TRANSFORM') {
4213
4186
  // Handle TRANSFORM objects specially to format FOR type_name LANGUAGE language_name correctly
4214
- const objects = node.objects.map((objList: any) => {
4187
+ const objects = node.objects.map((objList) => {
4215
4188
  if (objList && objList.List && objList.List.items) {
4216
- const items = objList.List.items.map((item: any) => {
4189
+ const items = objList.List.items.map((item) => {
4217
4190
  if (item.String && item.String.sval) {
4218
4191
  return item.String.sval;
4219
4192
  }
4220
4193
  return this.visit(item, context);
4221
- }).filter((name: string) => name && name.trim());
4194
+ }).filter((name) => name && name.trim());
4222
4195
  if (items.length === 2) {
4223
4196
  const [typeName, languageName] = items;
4224
4197
  return `FOR ${typeName} LANGUAGE ${languageName}`;
@@ -4227,30 +4200,30 @@ export class Deparser implements DeparserVisitor {
4227
4200
  }
4228
4201
  const objName = this.visit(objList, context);
4229
4202
  return objName;
4230
- }).filter((name: string) => name && name.trim()).join(', ');
4203
+ }).filter((name) => name && name.trim()).join(', ');
4231
4204
  if (objects) {
4232
4205
  output.push(objects);
4233
4206
  }
4234
4207
  }
4235
4208
  else {
4236
- const objects = node.objects.map((objList: any) => {
4209
+ const objects = node.objects.map((objList) => {
4237
4210
  if (Array.isArray(objList)) {
4238
4211
  const objName = objList.map(obj => this.visit(obj, context)).filter(name => name && name.trim()).join('.');
4239
4212
  return objName;
4240
4213
  }
4241
4214
  if (objList && objList.List && objList.List.items) {
4242
- const items = objList.List.items.map((item: any) => {
4215
+ const items = objList.List.items.map((item) => {
4243
4216
  if (item.String && item.String.sval) {
4244
4217
  return QuoteUtils.quote(item.String.sval);
4245
4218
  }
4246
4219
  return this.visit(item, context);
4247
- }).filter((name: string) => name && name.trim());
4220
+ }).filter((name) => name && name.trim());
4248
4221
  return items.join('.');
4249
4222
  }
4250
4223
  const objContext = context.spawn('DropStmt', { objtype: node.removeType });
4251
4224
  const objName = this.visit(objList, objContext);
4252
4225
  return objName;
4253
- }).filter((name: string) => name && name.trim()).join(', ');
4226
+ }).filter((name) => name && name.trim()).join(', ');
4254
4227
  if (objects) {
4255
4228
  output.push(objects);
4256
4229
  }
@@ -4262,11 +4235,11 @@ export class Deparser implements DeparserVisitor {
4262
4235
  // Only add RESTRICT if it was explicitly specified in the original SQL
4263
4236
  return output.join(' ');
4264
4237
  }
4265
- TruncateStmt(node: any, context: DeparserContext): string {
4266
- const output: string[] = ['TRUNCATE'];
4238
+ TruncateStmt(node, context) {
4239
+ const output = ['TRUNCATE'];
4267
4240
  if (node.relations && node.relations.length > 0) {
4268
4241
  const relations = node.relations
4269
- .map((relation: any) => this.visit(relation, context))
4242
+ .map((relation) => this.visit(relation, context))
4270
4243
  .join(', ');
4271
4244
  output.push(relations);
4272
4245
  }
@@ -4278,21 +4251,21 @@ export class Deparser implements DeparserVisitor {
4278
4251
  }
4279
4252
  return output.join(' ');
4280
4253
  }
4281
- ReturnStmt(node: any, context: DeparserContext): string {
4282
- const output: string[] = ['RETURN'];
4254
+ ReturnStmt(node, context) {
4255
+ const output = ['RETURN'];
4283
4256
  if (node.returnval) {
4284
4257
  const returnValue = this.visit(node.returnval, context);
4285
4258
  output.push(returnValue);
4286
4259
  }
4287
4260
  return output.join(' ');
4288
4261
  }
4289
- PLAssignStmt(node: any, context: DeparserContext): string {
4290
- const output: string[] = [];
4262
+ PLAssignStmt(node, context) {
4263
+ const output = [];
4291
4264
  if (node.name) {
4292
4265
  let nameWithIndirection = QuoteUtils.quote(node.name);
4293
4266
  if (node.indirection && node.indirection.length > 0) {
4294
4267
  const indirectionStr = node.indirection
4295
- .map((ind: any) => this.visit(ind, context))
4268
+ .map((ind) => this.visit(ind, context))
4296
4269
  .join('');
4297
4270
  nameWithIndirection += indirectionStr;
4298
4271
  }
@@ -4300,21 +4273,21 @@ export class Deparser implements DeparserVisitor {
4300
4273
  }
4301
4274
  output.push(':=');
4302
4275
  if (node.val) {
4303
- const valAny = node.val as any;
4276
+ const valAny = node.val;
4304
4277
  if (valAny.targetList) {
4305
4278
  output.push('SELECT');
4306
4279
  const targets = this.targetList(valAny.targetList, context);
4307
4280
  output.push(targets);
4308
4281
  }
4309
4282
  else {
4310
- const valueStr = this.visit(node.val as any, context);
4283
+ const valueStr = this.visit(node.val, context);
4311
4284
  output.push(valueStr);
4312
4285
  }
4313
4286
  }
4314
4287
  return output.join(' ');
4315
4288
  }
4316
- CopyStmt(node: any, context: DeparserContext): string {
4317
- const output: string[] = ['COPY'];
4289
+ CopyStmt(node, context) {
4290
+ const output = ['COPY'];
4318
4291
  if (node.relation) {
4319
4292
  const relationStr = this.RangeVar(node.relation, context);
4320
4293
  output.push(relationStr);
@@ -4358,8 +4331,8 @@ export class Deparser implements DeparserVisitor {
4358
4331
  }
4359
4332
  return output.join(' ');
4360
4333
  }
4361
- AlterTableStmt(node: any, context: DeparserContext): string {
4362
- const output: string[] = ['ALTER'];
4334
+ AlterTableStmt(node, context) {
4335
+ const output = ['ALTER'];
4363
4336
  if (node.objtype) {
4364
4337
  switch (node.objtype) {
4365
4338
  case 'OBJECT_TABLE':
@@ -4418,8 +4391,8 @@ export class Deparser implements DeparserVisitor {
4418
4391
  }
4419
4392
  return output.join(' ');
4420
4393
  }
4421
- AlterTableCmd(node: any, context: DeparserContext): string {
4422
- const output: string[] = [];
4394
+ AlterTableCmd(node, context) {
4395
+ const output = [];
4423
4396
  if (node.subtype) {
4424
4397
  switch (node.subtype) {
4425
4398
  case 'AT_AddColumn':
@@ -4435,8 +4408,8 @@ export class Deparser implements DeparserVisitor {
4435
4408
  if (node.def) {
4436
4409
  const colDefData = this.getNodeData(node.def);
4437
4410
  if (context.isPretty()) {
4438
- const parts: string[] = [];
4439
- const indentedParts: string[] = [];
4411
+ const parts = [];
4412
+ const indentedParts = [];
4440
4413
  if (colDefData.colname) {
4441
4414
  parts.push(QuoteUtils.quote(colDefData.colname));
4442
4415
  }
@@ -4473,7 +4446,7 @@ export class Deparser implements DeparserVisitor {
4473
4446
  }
4474
4447
  });
4475
4448
  }
4476
- if (colDefData.raw_default && !colDefData.constraints?.some((c: any) => {
4449
+ if (colDefData.raw_default && !colDefData.constraints?.some((c) => {
4477
4450
  const constraintStr = this.visit(c, context.spawn('ColumnDef', { isColumnConstraint: true }));
4478
4451
  return constraintStr === 'UNIQUE';
4479
4452
  })) {
@@ -4494,7 +4467,7 @@ export class Deparser implements DeparserVisitor {
4494
4467
  output.push(result);
4495
4468
  }
4496
4469
  else {
4497
- const parts: string[] = [];
4470
+ const parts = [];
4498
4471
  if (colDefData.colname) {
4499
4472
  parts.push(QuoteUtils.quote(colDefData.colname));
4500
4473
  }
@@ -4953,7 +4926,7 @@ export class Deparser implements DeparserVisitor {
4953
4926
  case 'AT_AlterConstraint':
4954
4927
  output.push('ALTER CONSTRAINT');
4955
4928
  if (node.def && this.getNodeType(node.def) === 'Constraint') {
4956
- const constraintData = this.getNodeData(node.def) as any;
4929
+ const constraintData = this.getNodeData(node.def);
4957
4930
  if (constraintData.conname) {
4958
4931
  output.push(QuoteUtils.quote(constraintData.conname));
4959
4932
  if (constraintData.deferrable !== undefined) {
@@ -5082,8 +5055,8 @@ export class Deparser implements DeparserVisitor {
5082
5055
  }
5083
5056
  return output.join(' ');
5084
5057
  }
5085
- CreateFunctionStmt(node: any, context: DeparserContext): string {
5086
- const output: string[] = ['CREATE'];
5058
+ CreateFunctionStmt(node, context) {
5059
+ const output = ['CREATE'];
5087
5060
  if (node.replace) {
5088
5061
  output.push('OR REPLACE');
5089
5062
  }
@@ -5094,14 +5067,14 @@ export class Deparser implements DeparserVisitor {
5094
5067
  output.push('FUNCTION');
5095
5068
  }
5096
5069
  if (node.funcname && node.funcname.length > 0) {
5097
- const funcName = node.funcname.map((name: any) => this.visit(name, context)).join('.');
5070
+ const funcName = node.funcname.map((name) => this.visit(name, context)).join('.');
5098
5071
  if (node.parameters && node.parameters.length > 0) {
5099
5072
  const params = node.parameters
5100
- .filter((param: any) => {
5073
+ .filter((param) => {
5101
5074
  const paramData = this.getNodeData(param);
5102
5075
  return paramData.mode !== 'FUNC_PARAM_TABLE';
5103
5076
  })
5104
- .map((param: any) => this.visit(param, context));
5077
+ .map((param) => this.visit(param, context));
5105
5078
  if (params.length > 0) {
5106
5079
  output.push(funcName + '(' + params.join(', ') + ')');
5107
5080
  }
@@ -5113,28 +5086,28 @@ export class Deparser implements DeparserVisitor {
5113
5086
  output.push(funcName + '()');
5114
5087
  }
5115
5088
  }
5116
- const hasTableParams = node.parameters && node.parameters.some((param: any) => {
5089
+ const hasTableParams = node.parameters && node.parameters.some((param) => {
5117
5090
  const paramData = this.getNodeData(param);
5118
5091
  return paramData.mode === 'FUNC_PARAM_TABLE';
5119
5092
  });
5120
5093
  if (hasTableParams) {
5121
5094
  output.push('RETURNS TABLE (');
5122
5095
  const tableParams = node.parameters
5123
- .filter((param: any) => {
5096
+ .filter((param) => {
5124
5097
  const paramData = this.getNodeData(param);
5125
5098
  return paramData.mode === 'FUNC_PARAM_TABLE';
5126
5099
  })
5127
- .map((param: any) => this.visit(param, context));
5100
+ .map((param) => this.visit(param, context));
5128
5101
  output.push(tableParams.join(', '));
5129
5102
  output.push(')');
5130
5103
  }
5131
5104
  else if (node.returnType) {
5132
5105
  output.push('RETURNS');
5133
- output.push(this.TypeName(node.returnType as any, context));
5106
+ output.push(this.TypeName(node.returnType, context));
5134
5107
  }
5135
5108
  if (node.options && node.options.length > 0) {
5136
5109
  const funcContext = context.spawn('CreateFunctionStmt');
5137
- const options = node.options.map((opt: any) => this.visit(opt, funcContext));
5110
+ const options = node.options.map((opt) => this.visit(opt, funcContext));
5138
5111
  output.push(...options);
5139
5112
  }
5140
5113
  if (node.sql_body) {
@@ -5180,8 +5153,8 @@ export class Deparser implements DeparserVisitor {
5180
5153
  }
5181
5154
  return output.join(' ');
5182
5155
  }
5183
- FunctionParameter(node: any, context: DeparserContext): string {
5184
- const output: string[] = [];
5156
+ FunctionParameter(node, context) {
5157
+ const output = [];
5185
5158
  if (node.mode) {
5186
5159
  switch (node.mode) {
5187
5160
  case 'FUNC_PARAM_IN':
@@ -5202,7 +5175,7 @@ export class Deparser implements DeparserVisitor {
5202
5175
  output.push(QuoteUtils.quote(node.name));
5203
5176
  }
5204
5177
  if (node.argType) {
5205
- output.push(this.TypeName(node.argType as any, context));
5178
+ output.push(this.TypeName(node.argType, context));
5206
5179
  }
5207
5180
  if (node.defexpr) {
5208
5181
  output.push('DEFAULT');
@@ -5210,8 +5183,8 @@ export class Deparser implements DeparserVisitor {
5210
5183
  }
5211
5184
  return output.join(' ');
5212
5185
  }
5213
- CreateEnumStmt(node: any, context: DeparserContext): string {
5214
- const output: string[] = ['CREATE', 'TYPE'];
5186
+ CreateEnumStmt(node, context) {
5187
+ const output = ['CREATE', 'TYPE'];
5215
5188
  if (node.typeName) {
5216
5189
  const typeName = ListUtils.unwrapList(node.typeName)
5217
5190
  .map(name => this.visit(name, context))
@@ -5231,8 +5204,8 @@ export class Deparser implements DeparserVisitor {
5231
5204
  }
5232
5205
  return output.join(' ');
5233
5206
  }
5234
- CreateDomainStmt(node: any, context: DeparserContext): string {
5235
- const output: string[] = ['CREATE', 'DOMAIN'];
5207
+ CreateDomainStmt(node, context) {
5208
+ const output = ['CREATE', 'DOMAIN'];
5236
5209
  if (node.domainname) {
5237
5210
  const domainName = ListUtils.unwrapList(node.domainname)
5238
5211
  .map(name => this.visit(name, context))
@@ -5256,8 +5229,8 @@ export class Deparser implements DeparserVisitor {
5256
5229
  }
5257
5230
  return output.join(' ');
5258
5231
  }
5259
- CreateRoleStmt(node: any, context: DeparserContext): string {
5260
- const output: string[] = ['CREATE'];
5232
+ CreateRoleStmt(node, context) {
5233
+ const output = ['CREATE'];
5261
5234
  if (node.stmt_type === 'ROLESTMT_ROLE') {
5262
5235
  output.push('ROLE');
5263
5236
  }
@@ -5285,7 +5258,7 @@ export class Deparser implements DeparserVisitor {
5285
5258
  }
5286
5259
  return output.join(' ');
5287
5260
  }
5288
- DefElem(node: any, context: DeparserContext): string {
5261
+ DefElem(node, context) {
5289
5262
  if (!node.defname) {
5290
5263
  return '';
5291
5264
  }
@@ -5560,10 +5533,10 @@ export class Deparser implements DeparserVisitor {
5560
5533
  if (context.parentNodeTypes.includes('CreateFunctionStmt') || context.parentNodeTypes.includes('AlterFunctionStmt')) {
5561
5534
  if (node.defname === 'as') {
5562
5535
  // Handle List type (multiple function body strings)
5563
- if (node.arg && (node.arg as any).List) {
5564
- const listNode = (node.arg as any).List;
5536
+ if (node.arg && node.arg.List) {
5537
+ const listNode = node.arg.List;
5565
5538
  const listItems = listNode.items || [];
5566
- const bodyParts = listItems.map((item: any) => {
5539
+ const bodyParts = listItems.map((item) => {
5567
5540
  if (item.String) {
5568
5541
  return item.String.sval;
5569
5542
  }
@@ -5575,7 +5548,7 @@ export class Deparser implements DeparserVisitor {
5575
5548
  return `AS ${delimiter}${body}${delimiter}`;
5576
5549
  }
5577
5550
  else {
5578
- return `AS ${bodyParts.map((part: string) => {
5551
+ return `AS ${bodyParts.map((part) => {
5579
5552
  const delimiter = this.getFunctionDelimiter(part);
5580
5553
  return `${delimiter}${part}${delimiter}`;
5581
5554
  }).join(', ')}`;
@@ -5818,8 +5791,8 @@ export class Deparser implements DeparserVisitor {
5818
5791
  }
5819
5792
  return node.defname.toUpperCase();
5820
5793
  }
5821
- CreateTableSpaceStmt(node: any, context: DeparserContext): string {
5822
- const output: string[] = ['CREATE', 'TABLESPACE'];
5794
+ CreateTableSpaceStmt(node, context) {
5795
+ const output = ['CREATE', 'TABLESPACE'];
5823
5796
  if (node.tablespacename) {
5824
5797
  output.push(node.tablespacename);
5825
5798
  }
@@ -5841,8 +5814,8 @@ export class Deparser implements DeparserVisitor {
5841
5814
  }
5842
5815
  return output.join(' ');
5843
5816
  }
5844
- DropTableSpaceStmt(node: any, context: DeparserContext): string {
5845
- const output: string[] = ['DROP', 'TABLESPACE'];
5817
+ DropTableSpaceStmt(node, context) {
5818
+ const output = ['DROP', 'TABLESPACE'];
5846
5819
  if (node.missing_ok) {
5847
5820
  output.push('IF', 'EXISTS');
5848
5821
  }
@@ -5851,8 +5824,8 @@ export class Deparser implements DeparserVisitor {
5851
5824
  }
5852
5825
  return output.join(' ');
5853
5826
  }
5854
- AlterTableSpaceOptionsStmt(node: any, context: DeparserContext): string {
5855
- const output: string[] = ['ALTER', 'TABLESPACE'];
5827
+ AlterTableSpaceOptionsStmt(node, context) {
5828
+ const output = ['ALTER', 'TABLESPACE'];
5856
5829
  if (node.tablespacename) {
5857
5830
  output.push(node.tablespacename);
5858
5831
  }
@@ -5871,8 +5844,8 @@ export class Deparser implements DeparserVisitor {
5871
5844
  }
5872
5845
  return output.join(' ');
5873
5846
  }
5874
- CreateExtensionStmt(node: any, context: DeparserContext): string {
5875
- const output: string[] = ['CREATE', 'EXTENSION'];
5847
+ CreateExtensionStmt(node, context) {
5848
+ const output = ['CREATE', 'EXTENSION'];
5876
5849
  if (node.if_not_exists) {
5877
5850
  output.push('IF', 'NOT', 'EXISTS');
5878
5851
  }
@@ -5888,8 +5861,8 @@ export class Deparser implements DeparserVisitor {
5888
5861
  }
5889
5862
  return output.join(' ');
5890
5863
  }
5891
- AlterExtensionStmt(node: any, context: DeparserContext): string {
5892
- const output: string[] = ['ALTER', 'EXTENSION'];
5864
+ AlterExtensionStmt(node, context) {
5865
+ const output = ['ALTER', 'EXTENSION'];
5893
5866
  if (node.extname) {
5894
5867
  output.push(this.quoteIfNeeded(node.extname));
5895
5868
  }
@@ -5902,8 +5875,8 @@ export class Deparser implements DeparserVisitor {
5902
5875
  }
5903
5876
  return output.join(' ');
5904
5877
  }
5905
- CreateFdwStmt(node: any, context: DeparserContext): string {
5906
- const output: string[] = ['CREATE', 'FOREIGN', 'DATA', 'WRAPPER'];
5878
+ CreateFdwStmt(node, context) {
5879
+ const output = ['CREATE', 'FOREIGN', 'DATA', 'WRAPPER'];
5907
5880
  if (node.fdwname) {
5908
5881
  output.push(node.fdwname);
5909
5882
  }
@@ -5924,8 +5897,8 @@ export class Deparser implements DeparserVisitor {
5924
5897
  }
5925
5898
  return output.join(' ');
5926
5899
  }
5927
- SetOperationStmt(node: any, context: DeparserContext): string {
5928
- const output: string[] = [];
5900
+ SetOperationStmt(node, context) {
5901
+ const output = [];
5929
5902
  if (node.larg) {
5930
5903
  output.push(this.visit(node.larg, context));
5931
5904
  }
@@ -5949,8 +5922,8 @@ export class Deparser implements DeparserVisitor {
5949
5922
  }
5950
5923
  return output.join(' ');
5951
5924
  }
5952
- ReplicaIdentityStmt(node: any, context: DeparserContext): string {
5953
- const output: string[] = [];
5925
+ ReplicaIdentityStmt(node, context) {
5926
+ const output = [];
5954
5927
  if (node.identity_type) {
5955
5928
  switch (node.identity_type) {
5956
5929
  case 'd':
@@ -5978,8 +5951,8 @@ export class Deparser implements DeparserVisitor {
5978
5951
  }
5979
5952
  return output.join(' ');
5980
5953
  }
5981
- AlterCollationStmt(node: any, context: DeparserContext): string {
5982
- const output: string[] = ['ALTER', 'COLLATION'];
5954
+ AlterCollationStmt(node, context) {
5955
+ const output = ['ALTER', 'COLLATION'];
5983
5956
  if (node.collname && node.collname.length > 0) {
5984
5957
  const collationName = ListUtils.unwrapList(node.collname)
5985
5958
  .map(name => this.visit(name, context))
@@ -5989,8 +5962,8 @@ export class Deparser implements DeparserVisitor {
5989
5962
  output.push('REFRESH', 'VERSION');
5990
5963
  return output.join(' ');
5991
5964
  }
5992
- AlterDomainStmt(node: any, context: DeparserContext): string {
5993
- const output: string[] = ['ALTER', 'DOMAIN'];
5965
+ AlterDomainStmt(node, context) {
5966
+ const output = ['ALTER', 'DOMAIN'];
5994
5967
  if (node.typeName && node.typeName.length > 0) {
5995
5968
  const domainName = ListUtils.unwrapList(node.typeName)
5996
5969
  .map(name => this.visit(name, context))
@@ -6087,8 +6060,8 @@ export class Deparser implements DeparserVisitor {
6087
6060
  }
6088
6061
  return output.join(' ');
6089
6062
  }
6090
- PrepareStmt(node: any, context: DeparserContext): string {
6091
- const output: string[] = ['PREPARE'];
6063
+ PrepareStmt(node, context) {
6064
+ const output = ['PREPARE'];
6092
6065
  if (node.name) {
6093
6066
  output.push(node.name);
6094
6067
  }
@@ -6104,8 +6077,8 @@ export class Deparser implements DeparserVisitor {
6104
6077
  }
6105
6078
  return output.join(' ');
6106
6079
  }
6107
- ExecuteStmt(node: any, context: DeparserContext): string {
6108
- const output: string[] = ['EXECUTE'];
6080
+ ExecuteStmt(node, context) {
6081
+ const output = ['EXECUTE'];
6109
6082
  if (node.name) {
6110
6083
  output.push(node.name);
6111
6084
  }
@@ -6117,8 +6090,8 @@ export class Deparser implements DeparserVisitor {
6117
6090
  }
6118
6091
  return output.join(' ');
6119
6092
  }
6120
- DeallocateStmt(node: any, context: DeparserContext): string {
6121
- const output: string[] = ['DEALLOCATE'];
6093
+ DeallocateStmt(node, context) {
6094
+ const output = ['DEALLOCATE'];
6122
6095
  if (node.isall) {
6123
6096
  output.push('ALL');
6124
6097
  }
@@ -6127,8 +6100,8 @@ export class Deparser implements DeparserVisitor {
6127
6100
  }
6128
6101
  return output.join(' ');
6129
6102
  }
6130
- NotifyStmt(node: any, context: DeparserContext): string {
6131
- const output: string[] = ['NOTIFY'];
6103
+ NotifyStmt(node, context) {
6104
+ const output = ['NOTIFY'];
6132
6105
  if (node.conditionname) {
6133
6106
  output.push(node.conditionname);
6134
6107
  }
@@ -6138,15 +6111,15 @@ export class Deparser implements DeparserVisitor {
6138
6111
  }
6139
6112
  return output.join(' ');
6140
6113
  }
6141
- ListenStmt(node: any, context: DeparserContext): string {
6142
- const output: string[] = ['LISTEN'];
6114
+ ListenStmt(node, context) {
6115
+ const output = ['LISTEN'];
6143
6116
  if (node.conditionname) {
6144
6117
  output.push(node.conditionname);
6145
6118
  }
6146
6119
  return output.join(' ');
6147
6120
  }
6148
- UnlistenStmt(node: any, context: DeparserContext): string {
6149
- const output: string[] = ['UNLISTEN'];
6121
+ UnlistenStmt(node, context) {
6122
+ const output = ['UNLISTEN'];
6150
6123
  if (node.conditionname) {
6151
6124
  output.push(node.conditionname);
6152
6125
  }
@@ -6155,16 +6128,16 @@ export class Deparser implements DeparserVisitor {
6155
6128
  }
6156
6129
  return output.join(' ');
6157
6130
  }
6158
- CheckPointStmt(node: any, context: DeparserContext): string {
6131
+ CheckPointStmt(node, context) {
6159
6132
  return 'CHECKPOINT';
6160
6133
  }
6161
- LoadStmt(node: any, context: DeparserContext): string {
6134
+ LoadStmt(node, context) {
6162
6135
  if (!node.filename) {
6163
6136
  throw new Error('LoadStmt requires filename');
6164
6137
  }
6165
6138
  return `LOAD '${node.filename}'`;
6166
6139
  }
6167
- DiscardStmt(node: any, context: DeparserContext): string {
6140
+ DiscardStmt(node, context) {
6168
6141
  switch (node.target) {
6169
6142
  case 'DISCARD_ALL':
6170
6143
  return 'DISCARD ALL';
@@ -6178,8 +6151,8 @@ export class Deparser implements DeparserVisitor {
6178
6151
  throw new Error(`Unsupported DiscardStmt target: ${node.target}`);
6179
6152
  }
6180
6153
  }
6181
- CommentStmt(node: any, context: DeparserContext): string {
6182
- const output: string[] = ['COMMENT ON'];
6154
+ CommentStmt(node, context) {
6155
+ const output = ['COMMENT ON'];
6183
6156
  if (node.objtype) {
6184
6157
  switch (node.objtype) {
6185
6158
  case 'OBJECT_TABLE':
@@ -6310,16 +6283,16 @@ export class Deparser implements DeparserVisitor {
6310
6283
  else if (node.objtype === 'OBJECT_OPERATOR') {
6311
6284
  // Handle OPERATOR syntax: COMMENT ON OPERATOR -(NONE, integer) IS 'comment'
6312
6285
  // For operators, we need to handle ObjectWithArgs structure
6313
- if (node.object && (node.object as any).ObjectWithArgs) {
6314
- const objWithArgs = (node.object as any).ObjectWithArgs;
6286
+ if (node.object && node.object.ObjectWithArgs) {
6287
+ const objWithArgs = node.object.ObjectWithArgs;
6315
6288
  let operatorName = objWithArgs.objname && objWithArgs.objname[0] && objWithArgs.objname[0].String
6316
6289
  ? objWithArgs.objname[0].String.sval : 'unknown';
6317
6290
  if (operatorName.startsWith('"') && operatorName.endsWith('"')) {
6318
6291
  operatorName = operatorName.slice(1, -1);
6319
6292
  }
6320
- const args: string[] = [];
6293
+ const args = [];
6321
6294
  if (objWithArgs.objargs) {
6322
- objWithArgs.objargs.forEach((arg: any) => {
6295
+ objWithArgs.objargs.forEach((arg) => {
6323
6296
  if (!arg || Object.keys(arg).length === 0) {
6324
6297
  args.push('NONE');
6325
6298
  }
@@ -6379,18 +6352,18 @@ export class Deparser implements DeparserVisitor {
6379
6352
  }
6380
6353
  }
6381
6354
  }
6382
- else if (node.objtype === 'OBJECT_OPERATOR' && node.object && (node.object as any).ObjectWithArgs) {
6355
+ else if (node.objtype === 'OBJECT_OPERATOR' && node.object && node.object.ObjectWithArgs) {
6383
6356
  // Handle direct ObjectWithArgs for OPERATOR syntax: COMMENT ON OPERATOR -(NONE, integer) IS 'comment'
6384
- const objWithArgs = (node.object as any).ObjectWithArgs;
6357
+ const objWithArgs = node.object.ObjectWithArgs;
6385
6358
  let operatorName = objWithArgs.objname && objWithArgs.objname[0] && objWithArgs.objname[0].String
6386
6359
  ? objWithArgs.objname[0].String.sval : 'unknown';
6387
6360
  // Remove quotes from operator name if present
6388
6361
  if (operatorName.startsWith('"') && operatorName.endsWith('"')) {
6389
6362
  operatorName = operatorName.slice(1, -1);
6390
6363
  }
6391
- const args: string[] = [];
6364
+ const args = [];
6392
6365
  if (objWithArgs.objargs) {
6393
- objWithArgs.objargs.forEach((arg: any) => {
6366
+ objWithArgs.objargs.forEach((arg) => {
6394
6367
  if (!arg || Object.keys(arg).length === 0) {
6395
6368
  args.push('NONE');
6396
6369
  }
@@ -6419,8 +6392,8 @@ export class Deparser implements DeparserVisitor {
6419
6392
  }
6420
6393
  return output.join(' ');
6421
6394
  }
6422
- LockStmt(node: any, context: DeparserContext): string {
6423
- const output: string[] = ['LOCK', 'TABLE'];
6395
+ LockStmt(node, context) {
6396
+ const output = ['LOCK', 'TABLE'];
6424
6397
  if (node.relations && node.relations.length > 0) {
6425
6398
  const relations = ListUtils.unwrapList(node.relations)
6426
6399
  .map(rel => this.visit(rel, context))
@@ -6448,8 +6421,8 @@ export class Deparser implements DeparserVisitor {
6448
6421
  }
6449
6422
  return output.join(' ');
6450
6423
  }
6451
- CreatePolicyStmt(node: any, context: DeparserContext): string {
6452
- const output: string[] = [];
6424
+ CreatePolicyStmt(node, context) {
6425
+ const output = [];
6453
6426
  const initialParts = ['CREATE', 'POLICY'];
6454
6427
  if (node.policy_name) {
6455
6428
  initialParts.push(QuoteUtils.quote(node.policy_name));
@@ -6526,8 +6499,8 @@ export class Deparser implements DeparserVisitor {
6526
6499
  }
6527
6500
  return context.isPretty() ? output.join('') : output.join(' ');
6528
6501
  }
6529
- AlterPolicyStmt(node: any, context: DeparserContext): string {
6530
- const output: string[] = ['ALTER', 'POLICY'];
6502
+ AlterPolicyStmt(node, context) {
6503
+ const output = ['ALTER', 'POLICY'];
6531
6504
  if (node.policy_name) {
6532
6505
  output.push(QuoteUtils.quote(node.policy_name));
6533
6506
  }
@@ -6550,8 +6523,8 @@ export class Deparser implements DeparserVisitor {
6550
6523
  }
6551
6524
  return output.join(' ');
6552
6525
  }
6553
- CreateUserMappingStmt(node: any, context: DeparserContext): string {
6554
- const output: string[] = ['CREATE'];
6526
+ CreateUserMappingStmt(node, context) {
6527
+ const output = ['CREATE'];
6555
6528
  if (node.if_not_exists) {
6556
6529
  output.push('IF', 'NOT', 'EXISTS');
6557
6530
  }
@@ -6575,8 +6548,8 @@ export class Deparser implements DeparserVisitor {
6575
6548
  }
6576
6549
  return output.join(' ');
6577
6550
  }
6578
- CreateStatsStmt(node: any, context: DeparserContext): string {
6579
- const output: string[] = ['CREATE'];
6551
+ CreateStatsStmt(node, context) {
6552
+ const output = ['CREATE'];
6580
6553
  if (node.if_not_exists) {
6581
6554
  output.push('IF', 'NOT', 'EXISTS');
6582
6555
  }
@@ -6601,7 +6574,7 @@ export class Deparser implements DeparserVisitor {
6601
6574
  }
6602
6575
  return output.join(' ');
6603
6576
  }
6604
- StatsElem(node: any, context: DeparserContext): string {
6577
+ StatsElem(node, context) {
6605
6578
  if (node.name) {
6606
6579
  return this.quoteIfNeeded(node.name);
6607
6580
  }
@@ -6610,8 +6583,8 @@ export class Deparser implements DeparserVisitor {
6610
6583
  }
6611
6584
  return '';
6612
6585
  }
6613
- CreatePublicationStmt(node: any, context: DeparserContext): string {
6614
- const output: string[] = ['CREATE', 'PUBLICATION'];
6586
+ CreatePublicationStmt(node, context) {
6587
+ const output = ['CREATE', 'PUBLICATION'];
6615
6588
  if (node.pubname) {
6616
6589
  output.push(`"${node.pubname}"`);
6617
6590
  }
@@ -6630,8 +6603,8 @@ export class Deparser implements DeparserVisitor {
6630
6603
  }
6631
6604
  return output.join(' ');
6632
6605
  }
6633
- CreateSubscriptionStmt(node: any, context: DeparserContext): string {
6634
- const output: string[] = ['CREATE', 'SUBSCRIPTION'];
6606
+ CreateSubscriptionStmt(node, context) {
6607
+ const output = ['CREATE', 'SUBSCRIPTION'];
6635
6608
  if (node.subname) {
6636
6609
  output.push(`"${node.subname}"`);
6637
6610
  }
@@ -6651,8 +6624,8 @@ export class Deparser implements DeparserVisitor {
6651
6624
  }
6652
6625
  return output.join(' ');
6653
6626
  }
6654
- AlterPublicationStmt(node: any, context: DeparserContext): string {
6655
- const output: string[] = ['ALTER', 'PUBLICATION'];
6627
+ AlterPublicationStmt(node, context) {
6628
+ const output = ['ALTER', 'PUBLICATION'];
6656
6629
  if (node.pubname) {
6657
6630
  output.push(`"${node.pubname}"`);
6658
6631
  }
@@ -6686,8 +6659,8 @@ export class Deparser implements DeparserVisitor {
6686
6659
  }
6687
6660
  return output.join(' ');
6688
6661
  }
6689
- AlterSubscriptionStmt(node: any, context: DeparserContext): string {
6690
- const output: string[] = ['ALTER', 'SUBSCRIPTION'];
6662
+ AlterSubscriptionStmt(node, context) {
6663
+ const output = ['ALTER', 'SUBSCRIPTION'];
6691
6664
  if (node.subname) {
6692
6665
  output.push(`"${node.subname}"`);
6693
6666
  }
@@ -6729,8 +6702,8 @@ export class Deparser implements DeparserVisitor {
6729
6702
  }
6730
6703
  return output.join(' ');
6731
6704
  }
6732
- DropSubscriptionStmt(node: any, context: DeparserContext): string {
6733
- const output: string[] = ['DROP', 'SUBSCRIPTION'];
6705
+ DropSubscriptionStmt(node, context) {
6706
+ const output = ['DROP', 'SUBSCRIPTION'];
6734
6707
  if (node.missing_ok) {
6735
6708
  output.push('IF EXISTS');
6736
6709
  }
@@ -6749,16 +6722,16 @@ export class Deparser implements DeparserVisitor {
6749
6722
  }
6750
6723
  return output.join(' ');
6751
6724
  }
6752
- DoStmt(node: any, context: DeparserContext): string {
6753
- const output: string[] = ['DO'];
6725
+ DoStmt(node, context) {
6726
+ const output = ['DO'];
6754
6727
  if (node.args && node.args.length > 0) {
6755
6728
  const doContext = context.spawn('DoStmt');
6756
6729
  const args = ListUtils.unwrapList(node.args);
6757
- const processedArgs: string[] = [];
6730
+ const processedArgs = [];
6758
6731
  for (const arg of args) {
6759
6732
  const nodeType = this.getNodeType(arg);
6760
6733
  if (nodeType === 'DefElem') {
6761
- const defElem = this.getNodeData(arg) as any;
6734
+ const defElem = this.getNodeData(arg);
6762
6735
  if (defElem.defname === 'language') {
6763
6736
  const langValue = this.visit(defElem.arg, doContext);
6764
6737
  processedArgs.push(`LANGUAGE ${langValue}`);
@@ -6767,7 +6740,7 @@ export class Deparser implements DeparserVisitor {
6767
6740
  // Handle code block with configurable delimiter
6768
6741
  const argNodeType = this.getNodeType(defElem.arg);
6769
6742
  if (argNodeType === 'String') {
6770
- const stringNode = this.getNodeData(defElem.arg) as any;
6743
+ const stringNode = this.getNodeData(defElem.arg);
6771
6744
  const delimiter = this.getFunctionDelimiter(stringNode.sval);
6772
6745
  processedArgs.push(`${delimiter}${stringNode.sval}${delimiter}`);
6773
6746
  }
@@ -6781,7 +6754,7 @@ export class Deparser implements DeparserVisitor {
6781
6754
  }
6782
6755
  return output.join(' ');
6783
6756
  }
6784
- private generateUniqueDollarTag(content: string): string {
6757
+ generateUniqueDollarTag(content) {
6785
6758
  // Check if content contains nested dollar quotes
6786
6759
  const dollarQuotePattern = /\$[a-zA-Z0-9_]*\$/g;
6787
6760
  const matches = content.match(dollarQuotePattern) || [];
@@ -6801,7 +6774,7 @@ export class Deparser implements DeparserVisitor {
6801
6774
  }
6802
6775
  return '$$';
6803
6776
  }
6804
- InlineCodeBlock(node: any, context: DeparserContext): string {
6777
+ InlineCodeBlock(node, context) {
6805
6778
  if (node.source_text) {
6806
6779
  const delimiter = this.getFunctionDelimiter(node.source_text);
6807
6780
  return `${delimiter}${node.source_text}${delimiter}`;
@@ -6809,14 +6782,14 @@ export class Deparser implements DeparserVisitor {
6809
6782
  const delimiter = this.options.functionDelimiter || '$$';
6810
6783
  return `${delimiter}${delimiter}`;
6811
6784
  }
6812
- CallContext(node: any, context: DeparserContext): string {
6785
+ CallContext(node, context) {
6813
6786
  if (node.atomic !== undefined) {
6814
6787
  return node.atomic ? 'ATOMIC' : 'NOT ATOMIC';
6815
6788
  }
6816
6789
  return '';
6817
6790
  }
6818
- ConstraintsSetStmt(node: any, context: DeparserContext): string {
6819
- const output: string[] = ['SET', 'CONSTRAINTS'];
6791
+ ConstraintsSetStmt(node, context) {
6792
+ const output = ['SET', 'CONSTRAINTS'];
6820
6793
  if (node.constraints && node.constraints.length > 0) {
6821
6794
  const constraints = ListUtils.unwrapList(node.constraints).map(constraint => this.visit(constraint, context));
6822
6795
  output.push(constraints.join(', '));
@@ -6827,8 +6800,8 @@ export class Deparser implements DeparserVisitor {
6827
6800
  output.push(node.deferred ? 'DEFERRED' : 'IMMEDIATE');
6828
6801
  return output.join(' ');
6829
6802
  }
6830
- AlterSystemStmt(node: any, context: DeparserContext): string {
6831
- const output: string[] = ['ALTER', 'SYSTEM'];
6803
+ AlterSystemStmt(node, context) {
6804
+ const output = ['ALTER', 'SYSTEM'];
6832
6805
  if (node.setstmt) {
6833
6806
  const setStmt = this.VariableSetStmt(node.setstmt, context);
6834
6807
  const setStmtWithoutPrefix = setStmt.replace(/^SET\s+/, '');
@@ -6836,8 +6809,8 @@ export class Deparser implements DeparserVisitor {
6836
6809
  }
6837
6810
  return output.join(' ');
6838
6811
  }
6839
- VacuumRelation(node: any, context: DeparserContext): string {
6840
- const output: string[] = [];
6812
+ VacuumRelation(node, context) {
6813
+ const output = [];
6841
6814
  if (node.relation) {
6842
6815
  output.push(this.RangeVar(node.relation, context));
6843
6816
  }
@@ -6849,8 +6822,8 @@ export class Deparser implements DeparserVisitor {
6849
6822
  }
6850
6823
  return output.join(' ');
6851
6824
  }
6852
- DropOwnedStmt(node: any, context: DeparserContext): string {
6853
- const output: string[] = ['DROP', 'OWNED', 'BY'];
6825
+ DropOwnedStmt(node, context) {
6826
+ const output = ['DROP', 'OWNED', 'BY'];
6854
6827
  if (node.roles && node.roles.length > 0) {
6855
6828
  const roles = ListUtils.unwrapList(node.roles).map(role => this.visit(role, context));
6856
6829
  output.push(roles.join(', '));
@@ -6867,8 +6840,8 @@ export class Deparser implements DeparserVisitor {
6867
6840
  }
6868
6841
  return output.join(' ');
6869
6842
  }
6870
- ReassignOwnedStmt(node: any, context: DeparserContext): string {
6871
- const output: string[] = ['REASSIGN', 'OWNED', 'BY'];
6843
+ ReassignOwnedStmt(node, context) {
6844
+ const output = ['REASSIGN', 'OWNED', 'BY'];
6872
6845
  if (node.roles && node.roles.length > 0) {
6873
6846
  const roles = ListUtils.unwrapList(node.roles).map(role => this.visit(role, context));
6874
6847
  output.push(roles.join(', '));
@@ -6879,8 +6852,8 @@ export class Deparser implements DeparserVisitor {
6879
6852
  }
6880
6853
  return output.join(' ');
6881
6854
  }
6882
- AlterTSDictionaryStmt(node: any, context: DeparserContext): string {
6883
- const output: string[] = ['ALTER', 'TEXT', 'SEARCH', 'DICTIONARY'];
6855
+ AlterTSDictionaryStmt(node, context) {
6856
+ const output = ['ALTER', 'TEXT', 'SEARCH', 'DICTIONARY'];
6884
6857
  if (node.dictname && node.dictname.length > 0) {
6885
6858
  const dictName = ListUtils.unwrapList(node.dictname).map(name => this.visit(name, context));
6886
6859
  output.push(dictName.join('.'));
@@ -6893,8 +6866,8 @@ export class Deparser implements DeparserVisitor {
6893
6866
  }
6894
6867
  return output.join(' ');
6895
6868
  }
6896
- AlterTSConfigurationStmt(node: any, context: DeparserContext): string {
6897
- const output: string[] = ['ALTER', 'TEXT', 'SEARCH', 'CONFIGURATION'];
6869
+ AlterTSConfigurationStmt(node, context) {
6870
+ const output = ['ALTER', 'TEXT', 'SEARCH', 'CONFIGURATION'];
6898
6871
  if (node.cfgname && node.cfgname.length > 0) {
6899
6872
  const cfgName = ListUtils.unwrapList(node.cfgname).map(name => this.visit(name, context));
6900
6873
  output.push(cfgName.join('.'));
@@ -6977,8 +6950,8 @@ export class Deparser implements DeparserVisitor {
6977
6950
  }
6978
6951
  return output.join(' ');
6979
6952
  }
6980
- ClosePortalStmt(node: any, context: DeparserContext): string {
6981
- const output: string[] = ['CLOSE'];
6953
+ ClosePortalStmt(node, context) {
6954
+ const output = ['CLOSE'];
6982
6955
  if (node.portalname) {
6983
6956
  output.push(QuoteUtils.quote(node.portalname));
6984
6957
  }
@@ -6987,10 +6960,10 @@ export class Deparser implements DeparserVisitor {
6987
6960
  }
6988
6961
  return output.join(' ');
6989
6962
  }
6990
- FetchStmt(node: any, context: DeparserContext): string {
6991
- const output: string[] = [node.ismove ? 'MOVE' : 'FETCH'];
6963
+ FetchStmt(node, context) {
6964
+ const output = [node.ismove ? 'MOVE' : 'FETCH'];
6992
6965
  // Check if howMany represents "ALL" (PostgreSQL uses LONG_MAX as sentinel)
6993
- const isAll = (node.howMany as any) === 9223372036854776000;
6966
+ const isAll = node.howMany === 9223372036854776000;
6994
6967
  // Handle direction first, then check for ALL within each direction
6995
6968
  if (node.direction) {
6996
6969
  switch (node.direction) {
@@ -7042,8 +7015,8 @@ export class Deparser implements DeparserVisitor {
7042
7015
  }
7043
7016
  return output.join(' ');
7044
7017
  }
7045
- AlterStatsStmt(node: any, context: DeparserContext): string {
7046
- const output: string[] = ['ALTER', 'STATISTICS'];
7018
+ AlterStatsStmt(node, context) {
7019
+ const output = ['ALTER', 'STATISTICS'];
7047
7020
  if (node.defnames && node.defnames.length > 0) {
7048
7021
  const names = ListUtils.unwrapList(node.defnames).map(name => this.visit(name, context));
7049
7022
  output.push(names.join('.'));
@@ -7054,7 +7027,7 @@ export class Deparser implements DeparserVisitor {
7054
7027
  }
7055
7028
  return output.join(' ');
7056
7029
  }
7057
- ObjectWithArgs(node: any, context: DeparserContext): string {
7030
+ ObjectWithArgs(node, context) {
7058
7031
  let result = '';
7059
7032
  if (node.objname && node.objname.length > 0) {
7060
7033
  const objContext = context.spawn('ObjectWithArgs');
@@ -7092,8 +7065,8 @@ export class Deparser implements DeparserVisitor {
7092
7065
  }
7093
7066
  return result;
7094
7067
  }
7095
- AlterOperatorStmt(node: any, context: DeparserContext): string {
7096
- const output: string[] = ['ALTER', 'OPERATOR'];
7068
+ AlterOperatorStmt(node, context) {
7069
+ const output = ['ALTER', 'OPERATOR'];
7097
7070
  if (node.opername) {
7098
7071
  output.push(this.ObjectWithArgs(node.opername, context));
7099
7072
  }
@@ -7105,8 +7078,8 @@ export class Deparser implements DeparserVisitor {
7105
7078
  }
7106
7079
  return output.join(' ');
7107
7080
  }
7108
- AlterFdwStmt(node: any, context: DeparserContext): string {
7109
- const output: string[] = ['ALTER', 'FOREIGN', 'DATA', 'WRAPPER'];
7081
+ AlterFdwStmt(node, context) {
7082
+ const output = ['ALTER', 'FOREIGN', 'DATA', 'WRAPPER'];
7110
7083
  if (node.fdwname) {
7111
7084
  output.push(QuoteUtils.quote(node.fdwname));
7112
7085
  }
@@ -7123,8 +7096,8 @@ export class Deparser implements DeparserVisitor {
7123
7096
  }
7124
7097
  return output.join(' ');
7125
7098
  }
7126
- CreateForeignServerStmt(node: any, context: DeparserContext): string {
7127
- const output: string[] = ['CREATE', 'SERVER'];
7099
+ CreateForeignServerStmt(node, context) {
7100
+ const output = ['CREATE', 'SERVER'];
7128
7101
  if (node.if_not_exists) {
7129
7102
  output.push('IF', 'NOT', 'EXISTS');
7130
7103
  }
@@ -7150,8 +7123,8 @@ export class Deparser implements DeparserVisitor {
7150
7123
  }
7151
7124
  return output.join(' ');
7152
7125
  }
7153
- AlterForeignServerStmt(node: any, context: DeparserContext): string {
7154
- const output: string[] = ['ALTER', 'SERVER'];
7126
+ AlterForeignServerStmt(node, context) {
7127
+ const output = ['ALTER', 'SERVER'];
7155
7128
  if (node.servername) {
7156
7129
  output.push(QuoteUtils.quote(node.servername));
7157
7130
  }
@@ -7168,8 +7141,8 @@ export class Deparser implements DeparserVisitor {
7168
7141
  }
7169
7142
  return output.join(' ');
7170
7143
  }
7171
- AlterUserMappingStmt(node: any, context: DeparserContext): string {
7172
- const output: string[] = ['ALTER', 'USER', 'MAPPING', 'FOR'];
7144
+ AlterUserMappingStmt(node, context) {
7145
+ const output = ['ALTER', 'USER', 'MAPPING', 'FOR'];
7173
7146
  if (node.user) {
7174
7147
  output.push(this.RoleSpec(node.user, context));
7175
7148
  }
@@ -7188,8 +7161,8 @@ export class Deparser implements DeparserVisitor {
7188
7161
  }
7189
7162
  return output.join(' ');
7190
7163
  }
7191
- DropUserMappingStmt(node: any, context: DeparserContext): string {
7192
- const output: string[] = ['DROP', 'USER', 'MAPPING'];
7164
+ DropUserMappingStmt(node, context) {
7165
+ const output = ['DROP', 'USER', 'MAPPING'];
7193
7166
  if (node.missing_ok) {
7194
7167
  output.push('IF', 'EXISTS');
7195
7168
  }
@@ -7206,8 +7179,8 @@ export class Deparser implements DeparserVisitor {
7206
7179
  }
7207
7180
  return output.join(' ');
7208
7181
  }
7209
- ImportForeignSchemaStmt(node: any, context: DeparserContext): string {
7210
- const output: string[] = ['IMPORT', 'FOREIGN', 'SCHEMA'];
7182
+ ImportForeignSchemaStmt(node, context) {
7183
+ const output = ['IMPORT', 'FOREIGN', 'SCHEMA'];
7211
7184
  if (node.remote_schema) {
7212
7185
  output.push(QuoteUtils.quote(node.remote_schema));
7213
7186
  }
@@ -7248,8 +7221,8 @@ export class Deparser implements DeparserVisitor {
7248
7221
  }
7249
7222
  return output.join(' ');
7250
7223
  }
7251
- ClusterStmt(node: any, context: DeparserContext): string {
7252
- const output: string[] = ['CLUSTER'];
7224
+ ClusterStmt(node, context) {
7225
+ const output = ['CLUSTER'];
7253
7226
  if (node.relation) {
7254
7227
  output.push(this.RangeVar(node.relation, context));
7255
7228
  if (node.indexname) {
@@ -7262,8 +7235,8 @@ export class Deparser implements DeparserVisitor {
7262
7235
  }
7263
7236
  return output.join(' ');
7264
7237
  }
7265
- VacuumStmt(node: any, context: DeparserContext): string {
7266
- const output: string[] = [node.is_vacuumcmd ? 'VACUUM' : 'ANALYZE'];
7238
+ VacuumStmt(node, context) {
7239
+ const output = [node.is_vacuumcmd ? 'VACUUM' : 'ANALYZE'];
7267
7240
  if (node.options && node.options.length > 0) {
7268
7241
  const options = ListUtils.unwrapList(node.options).map(option => this.visit(option, context));
7269
7242
  output.push(`(${options.join(', ')})`);
@@ -7274,8 +7247,8 @@ export class Deparser implements DeparserVisitor {
7274
7247
  }
7275
7248
  return output.join(' ');
7276
7249
  }
7277
- ExplainStmt(node: any, context: DeparserContext): string {
7278
- const output: string[] = ['EXPLAIN'];
7250
+ ExplainStmt(node, context) {
7251
+ const output = ['EXPLAIN'];
7279
7252
  if (node.options && node.options.length > 0) {
7280
7253
  const explainContext = context.spawn('ExplainStmt');
7281
7254
  const options = ListUtils.unwrapList(node.options).map(option => this.visit(option, explainContext));
@@ -7286,8 +7259,8 @@ export class Deparser implements DeparserVisitor {
7286
7259
  }
7287
7260
  return output.join(' ');
7288
7261
  }
7289
- ReindexStmt(node: any, context: DeparserContext): string {
7290
- const output: string[] = ['REINDEX'];
7262
+ ReindexStmt(node, context) {
7263
+ const output = ['REINDEX'];
7291
7264
  if (node.params && node.params.length > 0) {
7292
7265
  const params = ListUtils.unwrapList(node.params).map(param => this.visit(param, context));
7293
7266
  output.push(`(${params.join(', ')})`);
@@ -7321,12 +7294,12 @@ export class Deparser implements DeparserVisitor {
7321
7294
  }
7322
7295
  return output.join(' ');
7323
7296
  }
7324
- CallStmt(node: any, context: DeparserContext): string {
7325
- const output: string[] = ['CALL'];
7297
+ CallStmt(node, context) {
7298
+ const output = ['CALL'];
7326
7299
  if (node.funccall) {
7327
- const funcCall = node.funccall as any;
7300
+ const funcCall = node.funccall;
7328
7301
  if (funcCall.funcname && funcCall.funcname.length > 0) {
7329
- const funcNameParts = funcCall.funcname.map((nameNode: any) => {
7302
+ const funcNameParts = funcCall.funcname.map((nameNode) => {
7330
7303
  if (nameNode.String) {
7331
7304
  return nameNode.String.sval;
7332
7305
  }
@@ -7335,7 +7308,7 @@ export class Deparser implements DeparserVisitor {
7335
7308
  const funcName = funcNameParts.join('.');
7336
7309
  let argsStr = '';
7337
7310
  if (funcCall.args && funcCall.args.length > 0) {
7338
- const argStrs = funcCall.args.map((arg: any) => this.visit(arg, context));
7311
+ const argStrs = funcCall.args.map((arg) => this.visit(arg, context));
7339
7312
  argsStr = `(${argStrs.join(', ')})`;
7340
7313
  }
7341
7314
  else {
@@ -7352,8 +7325,8 @@ export class Deparser implements DeparserVisitor {
7352
7325
  }
7353
7326
  return output.join(' ');
7354
7327
  }
7355
- CreatedbStmt(node: any, context: DeparserContext): string {
7356
- const output: string[] = ['CREATE DATABASE'];
7328
+ CreatedbStmt(node, context) {
7329
+ const output = ['CREATE DATABASE'];
7357
7330
  if (!node.dbname) {
7358
7331
  throw new Error('CreatedbStmt requires dbname');
7359
7332
  }
@@ -7366,8 +7339,8 @@ export class Deparser implements DeparserVisitor {
7366
7339
  }
7367
7340
  return output.join(' ');
7368
7341
  }
7369
- DropdbStmt(node: any, context: DeparserContext): string {
7370
- const output: string[] = ['DROP DATABASE'];
7342
+ DropdbStmt(node, context) {
7343
+ const output = ['DROP DATABASE'];
7371
7344
  if (node.missing_ok) {
7372
7345
  output.push('IF EXISTS');
7373
7346
  }
@@ -7383,8 +7356,8 @@ export class Deparser implements DeparserVisitor {
7383
7356
  }
7384
7357
  return output.join(' ');
7385
7358
  }
7386
- RenameStmt(node: any, context: DeparserContext): string {
7387
- const output: string[] = ['ALTER'];
7359
+ RenameStmt(node, context) {
7360
+ const output = ['ALTER'];
7388
7361
  if (!node.renameType) {
7389
7362
  throw new Error('RenameStmt requires renameType');
7390
7363
  }
@@ -7544,8 +7517,8 @@ export class Deparser implements DeparserVisitor {
7544
7517
  }
7545
7518
  else if (node.object) {
7546
7519
  // Handle operator family and operator class objects specially to format name USING access_method correctly
7547
- if ((node.renameType === 'OBJECT_OPFAMILY' || node.renameType === 'OBJECT_OPCLASS') && (node.object as any).List) {
7548
- const items = ListUtils.unwrapList(node.object as any);
7520
+ if ((node.renameType === 'OBJECT_OPFAMILY' || node.renameType === 'OBJECT_OPCLASS') && node.object.List) {
7521
+ const items = ListUtils.unwrapList(node.object);
7549
7522
  if (items.length === 2) {
7550
7523
  const accessMethod = items[0].String?.sval || '';
7551
7524
  const objectName = items[1].String?.sval || '';
@@ -7555,9 +7528,9 @@ export class Deparser implements DeparserVisitor {
7555
7528
  output.push(this.visit(node.object, context));
7556
7529
  }
7557
7530
  }
7558
- else if (node.renameType === 'OBJECT_SCHEMA' && (node.object as any).List) {
7531
+ else if (node.renameType === 'OBJECT_SCHEMA' && node.object.List) {
7559
7532
  // Handle schema names - extract from List structure
7560
- const items = ListUtils.unwrapList(node.object as any);
7533
+ const items = ListUtils.unwrapList(node.object);
7561
7534
  if (items.length > 0 && items[0].String) {
7562
7535
  output.push(this.quoteIfNeeded(items[0].String.sval));
7563
7536
  }
@@ -7603,8 +7576,8 @@ export class Deparser implements DeparserVisitor {
7603
7576
  }
7604
7577
  return output.join(' ');
7605
7578
  }
7606
- AlterOwnerStmt(node: any, context: DeparserContext): string {
7607
- const output: string[] = ['ALTER'];
7579
+ AlterOwnerStmt(node, context) {
7580
+ const output = ['ALTER'];
7608
7581
  if (!node.objectType) {
7609
7582
  throw new Error('AlterOwnerStmt requires objectType');
7610
7583
  }
@@ -7683,8 +7656,8 @@ export class Deparser implements DeparserVisitor {
7683
7656
  }
7684
7657
  else if (node.object) {
7685
7658
  // Handle operator family and operator class objects specially to format name USING access_method correctly
7686
- if ((node.objectType === 'OBJECT_OPFAMILY' || node.objectType === 'OBJECT_OPCLASS') && (node.object as any).List) {
7687
- const items = ListUtils.unwrapList(node.object as any);
7659
+ if ((node.objectType === 'OBJECT_OPFAMILY' || node.objectType === 'OBJECT_OPCLASS') && node.object.List) {
7660
+ const items = ListUtils.unwrapList(node.object);
7688
7661
  if (items.length === 2) {
7689
7662
  const accessMethod = items[0].String?.sval || '';
7690
7663
  const objectName = items[1].String?.sval || '';
@@ -7705,8 +7678,8 @@ export class Deparser implements DeparserVisitor {
7705
7678
  output.push(this.RoleSpec(node.newowner, context));
7706
7679
  return output.join(' ');
7707
7680
  }
7708
- GrantStmt(node: any, context: DeparserContext): string {
7709
- const output: string[] = [];
7681
+ GrantStmt(node, context) {
7682
+ const output = [];
7710
7683
  if (node.is_grant) {
7711
7684
  output.push('GRANT');
7712
7685
  }
@@ -7860,15 +7833,15 @@ export class Deparser implements DeparserVisitor {
7860
7833
  }
7861
7834
  return output.join(' ');
7862
7835
  }
7863
- GrantRoleStmt(node: any, context: DeparserContext): string {
7864
- const output: string[] = [];
7836
+ GrantRoleStmt(node, context) {
7837
+ const output = [];
7865
7838
  // Check for inherit, admin, and set options first to place them correctly
7866
7839
  let hasInheritOption = false;
7867
7840
  let hasAdminOption = false;
7868
7841
  let hasSetOption = false;
7869
- let inheritValue: boolean | undefined;
7870
- let adminValue: boolean | undefined;
7871
- let setValue: boolean | undefined;
7842
+ let inheritValue;
7843
+ let adminValue;
7844
+ let setValue;
7872
7845
  if (node.opt && node.opt.length > 0) {
7873
7846
  const options = ListUtils.unwrapList(node.opt);
7874
7847
  const inheritOption = options.find(opt => opt.DefElem && opt.DefElem.defname === 'inherit');
@@ -7921,7 +7894,7 @@ export class Deparser implements DeparserVisitor {
7921
7894
  output.push(grantees);
7922
7895
  }
7923
7896
  if (node.is_grant) {
7924
- const withOptions: string[] = [];
7897
+ const withOptions = [];
7925
7898
  if (hasAdminOption) {
7926
7899
  if (adminValue === true) {
7927
7900
  withOptions.push('ADMIN OPTION');
@@ -7955,8 +7928,8 @@ export class Deparser implements DeparserVisitor {
7955
7928
  }
7956
7929
  return output.join(' ');
7957
7930
  }
7958
- SecLabelStmt(node: any, context: DeparserContext): string {
7959
- const output: string[] = ['SECURITY LABEL'];
7931
+ SecLabelStmt(node, context) {
7932
+ const output = ['SECURITY LABEL'];
7960
7933
  if (node.provider) {
7961
7934
  output.push('FOR', `"${node.provider}"`);
7962
7935
  }
@@ -7997,8 +7970,8 @@ export class Deparser implements DeparserVisitor {
7997
7970
  }
7998
7971
  return output.join(' ');
7999
7972
  }
8000
- AlterDefaultPrivilegesStmt(node: any, context: DeparserContext): string {
8001
- const output: string[] = ['ALTER DEFAULT PRIVILEGES'];
7973
+ AlterDefaultPrivilegesStmt(node, context) {
7974
+ const output = ['ALTER DEFAULT PRIVILEGES'];
8002
7975
  if (node.options && node.options.length > 0) {
8003
7976
  const options = ListUtils.unwrapList(node.options);
8004
7977
  for (const option of options) {
@@ -8034,8 +8007,8 @@ export class Deparser implements DeparserVisitor {
8034
8007
  }
8035
8008
  return output.join(' ');
8036
8009
  }
8037
- CreateConversionStmt(node: any, context: DeparserContext): string {
8038
- const output: string[] = ['CREATE'];
8010
+ CreateConversionStmt(node, context) {
8011
+ const output = ['CREATE'];
8039
8012
  if (node.def) {
8040
8013
  output.push('DEFAULT');
8041
8014
  }
@@ -8061,8 +8034,8 @@ export class Deparser implements DeparserVisitor {
8061
8034
  }
8062
8035
  return output.join(' ');
8063
8036
  }
8064
- CreateCastStmt(node: any, context: DeparserContext): string {
8065
- const output: string[] = ['CREATE CAST'];
8037
+ CreateCastStmt(node, context) {
8038
+ const output = ['CREATE CAST'];
8066
8039
  output.push('(');
8067
8040
  if (node.sourcetype) {
8068
8041
  output.push(this.TypeName(node.sourcetype, context));
@@ -8101,8 +8074,8 @@ export class Deparser implements DeparserVisitor {
8101
8074
  }
8102
8075
  return output.join(' ');
8103
8076
  }
8104
- CreatePLangStmt(node: any, context: DeparserContext): string {
8105
- const output: string[] = ['CREATE'];
8077
+ CreatePLangStmt(node, context) {
8078
+ const output = ['CREATE'];
8106
8079
  if (node.replace) {
8107
8080
  output.push('OR REPLACE');
8108
8081
  }
@@ -8136,8 +8109,8 @@ export class Deparser implements DeparserVisitor {
8136
8109
  }
8137
8110
  return output.join(' ');
8138
8111
  }
8139
- CreateTransformStmt(node: any, context: DeparserContext): string {
8140
- const output: string[] = ['CREATE'];
8112
+ CreateTransformStmt(node, context) {
8113
+ const output = ['CREATE'];
8141
8114
  if (node.replace) {
8142
8115
  output.push('OR REPLACE');
8143
8116
  }
@@ -8150,23 +8123,23 @@ export class Deparser implements DeparserVisitor {
8150
8123
  output.push(QuoteUtils.quote(node.lang));
8151
8124
  }
8152
8125
  output.push('(');
8153
- const transforms: string[] = [];
8126
+ const transforms = [];
8154
8127
  if (node.fromsql) {
8155
8128
  // Handle ObjectWithArgs directly to avoid visitor routing issues
8156
- const fromSqlName = this.ObjectWithArgs(node.fromsql as any, context);
8129
+ const fromSqlName = this.ObjectWithArgs(node.fromsql, context);
8157
8130
  transforms.push(`FROM SQL WITH FUNCTION ${fromSqlName}`);
8158
8131
  }
8159
8132
  if (node.tosql) {
8160
8133
  // Handle ObjectWithArgs directly to avoid visitor routing issues
8161
- const toSqlName = this.ObjectWithArgs(node.tosql as any, context);
8134
+ const toSqlName = this.ObjectWithArgs(node.tosql, context);
8162
8135
  transforms.push(`TO SQL WITH FUNCTION ${toSqlName}`);
8163
8136
  }
8164
8137
  output.push(transforms.join(', '));
8165
8138
  output.push(')');
8166
8139
  return output.join(' ');
8167
8140
  }
8168
- CreateTrigStmt(node: any, context: DeparserContext): string {
8169
- const output: string[] = ['CREATE'];
8141
+ CreateTrigStmt(node, context) {
8142
+ const output = ['CREATE'];
8170
8143
  if (node.replace) {
8171
8144
  output.push('OR REPLACE');
8172
8145
  }
@@ -8178,15 +8151,15 @@ export class Deparser implements DeparserVisitor {
8178
8151
  output.push(QuoteUtils.quote(node.trigname));
8179
8152
  }
8180
8153
  if (context.isPretty()) {
8181
- const components: string[] = [];
8182
- const timing: string[] = [];
8154
+ const components = [];
8155
+ const timing = [];
8183
8156
  if (node.timing & 2)
8184
8157
  timing.push('BEFORE');
8185
8158
  else if (node.timing & 64)
8186
8159
  timing.push('INSTEAD OF');
8187
8160
  else
8188
8161
  timing.push('AFTER');
8189
- const events: string[] = [];
8162
+ const events = [];
8190
8163
  if (node.events & 4)
8191
8164
  events.push('INSERT');
8192
8165
  if (node.events & 8)
@@ -8250,7 +8223,7 @@ export class Deparser implements DeparserVisitor {
8250
8223
  return output.join(' ') + context.newline() + components.join(context.newline());
8251
8224
  }
8252
8225
  else {
8253
- const timing: string[] = [];
8226
+ const timing = [];
8254
8227
  if (node.timing & 2)
8255
8228
  timing.push('BEFORE');
8256
8229
  else if (node.timing & 64)
@@ -8258,7 +8231,7 @@ export class Deparser implements DeparserVisitor {
8258
8231
  else
8259
8232
  timing.push('AFTER');
8260
8233
  output.push(timing.join(' '));
8261
- const events: string[] = [];
8234
+ const events = [];
8262
8235
  if (node.events & 4)
8263
8236
  events.push('INSERT');
8264
8237
  if (node.events & 8)
@@ -8330,8 +8303,8 @@ export class Deparser implements DeparserVisitor {
8330
8303
  return output.join(' ');
8331
8304
  }
8332
8305
  }
8333
- TriggerTransition(node: any, context: DeparserContext): string {
8334
- const output: string[] = [];
8306
+ TriggerTransition(node, context) {
8307
+ const output = [];
8335
8308
  if (node.isNew) {
8336
8309
  output.push('NEW TABLE AS');
8337
8310
  }
@@ -8343,8 +8316,8 @@ export class Deparser implements DeparserVisitor {
8343
8316
  }
8344
8317
  return output.join(' ');
8345
8318
  }
8346
- CreateEventTrigStmt(node: any, context: DeparserContext): string {
8347
- const output: string[] = ['CREATE EVENT TRIGGER'];
8319
+ CreateEventTrigStmt(node, context) {
8320
+ const output = ['CREATE EVENT TRIGGER'];
8348
8321
  if (node.trigname) {
8349
8322
  output.push(QuoteUtils.quote(node.trigname));
8350
8323
  }
@@ -8369,8 +8342,8 @@ export class Deparser implements DeparserVisitor {
8369
8342
  }
8370
8343
  return output.join(' ');
8371
8344
  }
8372
- AlterEventTrigStmt(node: any, context: DeparserContext): string {
8373
- const output: string[] = ['ALTER EVENT TRIGGER'];
8345
+ AlterEventTrigStmt(node, context) {
8346
+ const output = ['ALTER EVENT TRIGGER'];
8374
8347
  if (node.trigname) {
8375
8348
  output.push(QuoteUtils.quote(node.trigname));
8376
8349
  }
@@ -8394,8 +8367,8 @@ export class Deparser implements DeparserVisitor {
8394
8367
  }
8395
8368
  return output.join(' ');
8396
8369
  }
8397
- CreateOpClassStmt(node: any, context: DeparserContext): string {
8398
- const output: string[] = ['CREATE OPERATOR CLASS'];
8370
+ CreateOpClassStmt(node, context) {
8371
+ const output = ['CREATE OPERATOR CLASS'];
8399
8372
  if (node.opclassname && node.opclassname.length > 0) {
8400
8373
  const className = ListUtils.unwrapList(node.opclassname)
8401
8374
  .map(name => this.visit(name, context))
@@ -8429,8 +8402,8 @@ export class Deparser implements DeparserVisitor {
8429
8402
  }
8430
8403
  return output.join(' ');
8431
8404
  }
8432
- CreateOpFamilyStmt(node: any, context: DeparserContext): string {
8433
- const output: string[] = ['CREATE OPERATOR FAMILY'];
8405
+ CreateOpFamilyStmt(node, context) {
8406
+ const output = ['CREATE OPERATOR FAMILY'];
8434
8407
  if (node.opfamilyname && node.opfamilyname.length > 0) {
8435
8408
  const familyName = ListUtils.unwrapList(node.opfamilyname)
8436
8409
  .map(name => this.visit(name, context))
@@ -8443,8 +8416,8 @@ export class Deparser implements DeparserVisitor {
8443
8416
  }
8444
8417
  return output.join(' ');
8445
8418
  }
8446
- AlterOpFamilyStmt(node: any, context: DeparserContext): string {
8447
- const output: string[] = ['ALTER OPERATOR FAMILY'];
8419
+ AlterOpFamilyStmt(node, context) {
8420
+ const output = ['ALTER OPERATOR FAMILY'];
8448
8421
  if (node.opfamilyname && node.opfamilyname.length > 0) {
8449
8422
  const familyName = ListUtils.unwrapList(node.opfamilyname)
8450
8423
  .map(name => this.visit(name, context))
@@ -8469,8 +8442,8 @@ export class Deparser implements DeparserVisitor {
8469
8442
  }
8470
8443
  return output.join(' ');
8471
8444
  }
8472
- MergeStmt(node: any, context: DeparserContext): string {
8473
- const output: string[] = [];
8445
+ MergeStmt(node, context) {
8446
+ const output = [];
8474
8447
  if (node.withClause) {
8475
8448
  output.push(this.WithClause(node.withClause, context));
8476
8449
  }
@@ -8494,8 +8467,8 @@ export class Deparser implements DeparserVisitor {
8494
8467
  }
8495
8468
  return output.join(' ');
8496
8469
  }
8497
- AlterTableMoveAllStmt(node: any, context: DeparserContext): string {
8498
- const output: string[] = ['ALTER'];
8470
+ AlterTableMoveAllStmt(node, context) {
8471
+ const output = ['ALTER'];
8499
8472
  if (node.objtype === 'OBJECT_TABLE') {
8500
8473
  output.push('TABLE');
8501
8474
  }
@@ -8518,11 +8491,11 @@ export class Deparser implements DeparserVisitor {
8518
8491
  }
8519
8492
  return output.join(' ');
8520
8493
  }
8521
- CreateSeqStmt(node: any, context: DeparserContext): string {
8522
- const output: string[] = ['CREATE'];
8494
+ CreateSeqStmt(node, context) {
8495
+ const output = ['CREATE'];
8523
8496
  // Check if this is a temporary sequence
8524
8497
  if (node.sequence) {
8525
- const seq = node.sequence as any;
8498
+ const seq = node.sequence;
8526
8499
  if (seq.relpersistence === 't') {
8527
8500
  output.push('TEMPORARY');
8528
8501
  }
@@ -8532,8 +8505,8 @@ export class Deparser implements DeparserVisitor {
8532
8505
  output.push('IF NOT EXISTS');
8533
8506
  }
8534
8507
  if (node.sequence) {
8535
- const sequenceName: string[] = [];
8536
- const seq = node.sequence as any;
8508
+ const sequenceName = [];
8509
+ const seq = node.sequence;
8537
8510
  if (seq.schemaname) {
8538
8511
  sequenceName.push(QuoteUtils.quote(seq.schemaname));
8539
8512
  }
@@ -8563,14 +8536,14 @@ export class Deparser implements DeparserVisitor {
8563
8536
  }
8564
8537
  return output.join(' ');
8565
8538
  }
8566
- AlterSeqStmt(node: any, context: DeparserContext): string {
8567
- const output: string[] = ['ALTER', 'SEQUENCE'];
8539
+ AlterSeqStmt(node, context) {
8540
+ const output = ['ALTER', 'SEQUENCE'];
8568
8541
  if (node.missing_ok) {
8569
8542
  output.push('IF EXISTS');
8570
8543
  }
8571
8544
  if (node.sequence) {
8572
- const sequenceName: string[] = [];
8573
- const seq = node.sequence as any;
8545
+ const sequenceName = [];
8546
+ const seq = node.sequence;
8574
8547
  if (seq.schemaname) {
8575
8548
  sequenceName.push(QuoteUtils.quote(seq.schemaname));
8576
8549
  }
@@ -8606,8 +8579,8 @@ export class Deparser implements DeparserVisitor {
8606
8579
  }
8607
8580
  return output.join(' ');
8608
8581
  }
8609
- CompositeTypeStmt(node: any, context: DeparserContext): string {
8610
- const output: string[] = ['CREATE', 'TYPE'];
8582
+ CompositeTypeStmt(node, context) {
8583
+ const output = ['CREATE', 'TYPE'];
8611
8584
  if (node.typevar) {
8612
8585
  const typeContext = context.spawn('CompositeTypeStmt');
8613
8586
  output.push(this.RangeVar(node.typevar, typeContext));
@@ -8625,8 +8598,8 @@ export class Deparser implements DeparserVisitor {
8625
8598
  }
8626
8599
  return output.join(' ');
8627
8600
  }
8628
- CreateRangeStmt(node: any, context: DeparserContext): string {
8629
- const output: string[] = ['CREATE', 'TYPE'];
8601
+ CreateRangeStmt(node, context) {
8602
+ const output = ['CREATE', 'TYPE'];
8630
8603
  if (node.typeName && node.typeName.length > 0) {
8631
8604
  const typeNameStr = ListUtils.unwrapList(node.typeName)
8632
8605
  .map(name => this.visit(name, context))
@@ -8647,8 +8620,8 @@ export class Deparser implements DeparserVisitor {
8647
8620
  }
8648
8621
  return output.join(' ');
8649
8622
  }
8650
- AlterEnumStmt(node: any, context: DeparserContext): string {
8651
- const output: string[] = ['ALTER', 'TYPE'];
8623
+ AlterEnumStmt(node, context) {
8624
+ const output = ['ALTER', 'TYPE'];
8652
8625
  if (node.typeName && node.typeName.length > 0) {
8653
8626
  const typeNameStr = ListUtils.unwrapList(node.typeName)
8654
8627
  .map(name => this.visit(name, context))
@@ -8679,8 +8652,8 @@ export class Deparser implements DeparserVisitor {
8679
8652
  }
8680
8653
  return output.join(' ');
8681
8654
  }
8682
- AlterTypeStmt(node: any, context: DeparserContext): string {
8683
- const output: string[] = ['ALTER', 'TYPE'];
8655
+ AlterTypeStmt(node, context) {
8656
+ const output = ['ALTER', 'TYPE'];
8684
8657
  if (node.typeName && node.typeName.length > 0) {
8685
8658
  const typeNameStr = ListUtils.unwrapList(node.typeName)
8686
8659
  .map(name => this.visit(name, context))
@@ -8701,11 +8674,11 @@ export class Deparser implements DeparserVisitor {
8701
8674
  }
8702
8675
  return output.join(' ');
8703
8676
  }
8704
- AlterRoleStmt(node: any, context: DeparserContext): string {
8677
+ AlterRoleStmt(node, context) {
8705
8678
  // Check if this is an ALTER GROUP statement by looking for rolemembers DefElem
8706
8679
  const isGroupStatement = node.options &&
8707
8680
  ListUtils.unwrapList(node.options).some(option => option.DefElem && option.DefElem.defname === 'rolemembers');
8708
- const output: string[] = ['ALTER', isGroupStatement ? 'GROUP' : 'ROLE'];
8681
+ const output = ['ALTER', isGroupStatement ? 'GROUP' : 'ROLE'];
8709
8682
  if (node.role) {
8710
8683
  output.push(this.RoleSpec(node.role, context));
8711
8684
  }
@@ -8736,8 +8709,8 @@ export class Deparser implements DeparserVisitor {
8736
8709
  }
8737
8710
  return output.join(' ');
8738
8711
  }
8739
- DropRoleStmt(node: any, context: DeparserContext): string {
8740
- const output: string[] = ['DROP', 'ROLE'];
8712
+ DropRoleStmt(node, context) {
8713
+ const output = ['DROP', 'ROLE'];
8741
8714
  if (node.missing_ok) {
8742
8715
  output.push('IF EXISTS');
8743
8716
  }
@@ -8749,14 +8722,14 @@ export class Deparser implements DeparserVisitor {
8749
8722
  }
8750
8723
  return output.join(' ');
8751
8724
  }
8752
- targetList(node: any, context: DeparserContext): string {
8725
+ targetList(node, context) {
8753
8726
  if (!node || !Array.isArray(node)) {
8754
8727
  return '';
8755
8728
  }
8756
- return node.map((target: any) => this.visit(target, context)).join(', ');
8729
+ return node.map((target) => this.visit(target, context)).join(', ');
8757
8730
  }
8758
- CreateAggregateStmt(node: any, context: DeparserContext): string {
8759
- const output: string[] = ['CREATE'];
8731
+ CreateAggregateStmt(node, context) {
8732
+ const output = ['CREATE'];
8760
8733
  if (node.replace) {
8761
8734
  output.push('OR REPLACE');
8762
8735
  }
@@ -8780,7 +8753,7 @@ export class Deparser implements DeparserVisitor {
8780
8753
  }
8781
8754
  output.push(')');
8782
8755
  output.push('(');
8783
- const options: string[] = [];
8756
+ const options = [];
8784
8757
  if (node.definition && node.definition.length > 0) {
8785
8758
  const optionStrs = ListUtils.unwrapList(node.definition)
8786
8759
  .map(option => {
@@ -8829,8 +8802,8 @@ export class Deparser implements DeparserVisitor {
8829
8802
  output.push(')');
8830
8803
  return output.join(' ');
8831
8804
  }
8832
- CreateTableAsStmt(node: any, context: DeparserContext): string {
8833
- const output: string[] = ['CREATE'];
8805
+ CreateTableAsStmt(node, context) {
8806
+ const output = ['CREATE'];
8834
8807
  if (node.objtype === 'OBJECT_MATVIEW') {
8835
8808
  output.push('MATERIALIZED VIEW');
8836
8809
  }
@@ -8876,7 +8849,7 @@ export class Deparser implements DeparserVisitor {
8876
8849
  }
8877
8850
  output.push('AS');
8878
8851
  if (node.query) {
8879
- output.push(this.visit(node.query as any, context));
8852
+ output.push(this.visit(node.query, context));
8880
8853
  }
8881
8854
  if (node.into && node.into.options && node.into.options.length > 0) {
8882
8855
  output.push('WITH');
@@ -8890,21 +8863,21 @@ export class Deparser implements DeparserVisitor {
8890
8863
  }
8891
8864
  return output.join(' ');
8892
8865
  }
8893
- RefreshMatViewStmt(node: any, context: DeparserContext): string {
8894
- const output: string[] = ['REFRESH', 'MATERIALIZED', 'VIEW'];
8866
+ RefreshMatViewStmt(node, context) {
8867
+ const output = ['REFRESH', 'MATERIALIZED', 'VIEW'];
8895
8868
  if (node.concurrent) {
8896
8869
  output.push('CONCURRENTLY');
8897
8870
  }
8898
8871
  if (node.relation) {
8899
- output.push(this.visit(node.relation as any, context));
8872
+ output.push(this.visit(node.relation, context));
8900
8873
  }
8901
8874
  if (node.skipData) {
8902
8875
  output.push('WITH NO DATA');
8903
8876
  }
8904
8877
  return output.join(' ');
8905
8878
  }
8906
- AccessPriv(node: any, context: DeparserContext): string {
8907
- const output: string[] = [];
8879
+ AccessPriv(node, context) {
8880
+ const output = [];
8908
8881
  if (node.priv_name) {
8909
8882
  output.push(node.priv_name.toUpperCase());
8910
8883
  }
@@ -8920,14 +8893,14 @@ export class Deparser implements DeparserVisitor {
8920
8893
  }
8921
8894
  return output.join(' ');
8922
8895
  }
8923
- aliasname(node: any, context: DeparserContext): string {
8896
+ aliasname(node, context) {
8924
8897
  if (typeof node === 'string') {
8925
8898
  return QuoteUtils.quote(node);
8926
8899
  }
8927
8900
  return this.visit(node, context);
8928
8901
  }
8929
- DefineStmt(node: any, context: DeparserContext): string {
8930
- const output: string[] = [];
8902
+ DefineStmt(node, context) {
8903
+ const output = [];
8931
8904
  if (!node.kind) {
8932
8905
  throw new Error('DefineStmt requires kind property');
8933
8906
  }
@@ -9273,8 +9246,8 @@ export class Deparser implements DeparserVisitor {
9273
9246
  }
9274
9247
  return output.join(' ');
9275
9248
  }
9276
- AlterDatabaseStmt(node: any, context: DeparserContext): string {
9277
- const output: string[] = ['ALTER', 'DATABASE'];
9249
+ AlterDatabaseStmt(node, context) {
9250
+ const output = ['ALTER', 'DATABASE'];
9278
9251
  if (node.dbname) {
9279
9252
  output.push(QuoteUtils.quote(node.dbname));
9280
9253
  }
@@ -9284,16 +9257,16 @@ export class Deparser implements DeparserVisitor {
9284
9257
  }
9285
9258
  return output.join(' ');
9286
9259
  }
9287
- AlterDatabaseRefreshCollStmt(node: any, context: DeparserContext): string {
9288
- const output: string[] = ['ALTER', 'DATABASE'];
9260
+ AlterDatabaseRefreshCollStmt(node, context) {
9261
+ const output = ['ALTER', 'DATABASE'];
9289
9262
  if (node.dbname) {
9290
9263
  output.push(QuoteUtils.quote(node.dbname));
9291
9264
  }
9292
9265
  output.push('REFRESH', 'COLLATION', 'VERSION');
9293
9266
  return output.join(' ');
9294
9267
  }
9295
- AlterDatabaseSetStmt(node: any, context: DeparserContext): string {
9296
- const output: string[] = ['ALTER', 'DATABASE'];
9268
+ AlterDatabaseSetStmt(node, context) {
9269
+ const output = ['ALTER', 'DATABASE'];
9297
9270
  if (node.dbname) {
9298
9271
  output.push(QuoteUtils.quote(node.dbname));
9299
9272
  }
@@ -9303,13 +9276,13 @@ export class Deparser implements DeparserVisitor {
9303
9276
  }
9304
9277
  return output.join(' ');
9305
9278
  }
9306
- DeclareCursorStmt(node: any, context: DeparserContext): string {
9307
- const output: string[] = ['DECLARE'];
9279
+ DeclareCursorStmt(node, context) {
9280
+ const output = ['DECLARE'];
9308
9281
  if (node.portalname) {
9309
9282
  output.push(QuoteUtils.quote(node.portalname));
9310
9283
  }
9311
9284
  // Handle cursor options before CURSOR keyword
9312
- const cursorOptions: string[] = [];
9285
+ const cursorOptions = [];
9313
9286
  if (node.options) {
9314
9287
  if (node.options & 2) {
9315
9288
  cursorOptions.push('SCROLL');
@@ -9337,8 +9310,8 @@ export class Deparser implements DeparserVisitor {
9337
9310
  }
9338
9311
  return output.join(' ');
9339
9312
  }
9340
- PublicationObjSpec(node: any, context: DeparserContext): string {
9341
- const output: string[] = [];
9313
+ PublicationObjSpec(node, context) {
9314
+ const output = [];
9342
9315
  if (node.pubobjtype === 'PUBLICATIONOBJ_TABLE') {
9343
9316
  output.push('TABLE');
9344
9317
  if (node.pubtable) {
@@ -9356,8 +9329,8 @@ export class Deparser implements DeparserVisitor {
9356
9329
  }
9357
9330
  return output.join(' ');
9358
9331
  }
9359
- PublicationTable(node: any, context: DeparserContext): string {
9360
- const output: string[] = [];
9332
+ PublicationTable(node, context) {
9333
+ const output = [];
9361
9334
  if (node.relation) {
9362
9335
  output.push(this.RangeVar(node.relation, context));
9363
9336
  }
@@ -9371,8 +9344,8 @@ export class Deparser implements DeparserVisitor {
9371
9344
  }
9372
9345
  return output.join(' ');
9373
9346
  }
9374
- CreateAmStmt(node: any, context: DeparserContext): string {
9375
- const output: string[] = ['CREATE', 'ACCESS', 'METHOD'];
9347
+ CreateAmStmt(node, context) {
9348
+ const output = ['CREATE', 'ACCESS', 'METHOD'];
9376
9349
  if (node.amname) {
9377
9350
  output.push(QuoteUtils.quote(node.amname));
9378
9351
  }
@@ -9398,8 +9371,8 @@ export class Deparser implements DeparserVisitor {
9398
9371
  }
9399
9372
  return output.join(' ');
9400
9373
  }
9401
- IntoClause(node: any, context: DeparserContext): string {
9402
- const output: string[] = [];
9374
+ IntoClause(node, context) {
9375
+ const output = [];
9403
9376
  if (node.rel) {
9404
9377
  output.push(this.RangeVar(node.rel, context));
9405
9378
  }
@@ -9438,8 +9411,8 @@ export class Deparser implements DeparserVisitor {
9438
9411
  }
9439
9412
  return output.join(' ');
9440
9413
  }
9441
- OnConflictExpr(node: any, context: DeparserContext): string {
9442
- const output: string[] = ['ON CONFLICT'];
9414
+ OnConflictExpr(node, context) {
9415
+ const output = ['ON CONFLICT'];
9443
9416
  if (node.arbiterElems && node.arbiterElems.length > 0) {
9444
9417
  const arbiters = ListUtils.unwrapList(node.arbiterElems)
9445
9418
  .map(elem => this.visit(elem, context))
@@ -9468,11 +9441,11 @@ export class Deparser implements DeparserVisitor {
9468
9441
  }
9469
9442
  return output.join(' ');
9470
9443
  }
9471
- ScanToken(node: any, context: DeparserContext): string {
9444
+ ScanToken(node, context) {
9472
9445
  return '';
9473
9446
  }
9474
- CreateOpClassItem(node: any, context: DeparserContext): string {
9475
- const output: string[] = [];
9447
+ CreateOpClassItem(node, context) {
9448
+ const output = [];
9476
9449
  if (node.itemtype === 1) {
9477
9450
  output.push('OPERATOR');
9478
9451
  // For operators, always include the number (default to 0 if undefined)
@@ -9514,14 +9487,14 @@ export class Deparser implements DeparserVisitor {
9514
9487
  }
9515
9488
  return output.join(' ');
9516
9489
  }
9517
- Var(node: any, context: DeparserContext): string {
9490
+ Var(node, context) {
9518
9491
  if (node.varno && node.varattno) {
9519
9492
  return `$${node.varno}.${node.varattno}`;
9520
9493
  }
9521
9494
  return '$var';
9522
9495
  }
9523
- TableFunc(node: any, context: DeparserContext): string {
9524
- const output: string[] = [];
9496
+ TableFunc(node, context) {
9497
+ const output = [];
9525
9498
  if (node.functype === 'TFT_XMLTABLE') {
9526
9499
  output.push('XMLTABLE');
9527
9500
  if (node.ns_names && node.ns_names.length > 0) {
@@ -9565,8 +9538,8 @@ export class Deparser implements DeparserVisitor {
9565
9538
  }
9566
9539
  return output.join(' ');
9567
9540
  }
9568
- RangeTableFunc(node: any, context: DeparserContext): string {
9569
- const output: string[] = [];
9541
+ RangeTableFunc(node, context) {
9542
+ const output = [];
9570
9543
  if (node.lateral) {
9571
9544
  output.push('LATERAL');
9572
9545
  }
@@ -9589,8 +9562,8 @@ export class Deparser implements DeparserVisitor {
9589
9562
  }
9590
9563
  return output.join(' ');
9591
9564
  }
9592
- RangeTableFuncCol(node: any, context: DeparserContext): string {
9593
- const output: string[] = [];
9565
+ RangeTableFuncCol(node, context) {
9566
+ const output = [];
9594
9567
  if (node.colname) {
9595
9568
  output.push(QuoteUtils.quote(node.colname));
9596
9569
  }
@@ -9610,8 +9583,8 @@ export class Deparser implements DeparserVisitor {
9610
9583
  }
9611
9584
  return output.join(' ');
9612
9585
  }
9613
- JsonArrayQueryConstructor(node: any, context: DeparserContext): string {
9614
- const output: string[] = ['JSON_ARRAYAGG'];
9586
+ JsonArrayQueryConstructor(node, context) {
9587
+ const output = ['JSON_ARRAYAGG'];
9615
9588
  if (node.query) {
9616
9589
  output.push(`(${this.visit(node.query, context)})`);
9617
9590
  }
@@ -9629,8 +9602,8 @@ export class Deparser implements DeparserVisitor {
9629
9602
  }
9630
9603
  return output.join(' ');
9631
9604
  }
9632
- RangeFunction(node: any, context: DeparserContext): string {
9633
- const output: string[] = [];
9605
+ RangeFunction(node, context) {
9606
+ const output = [];
9634
9607
  if (node.lateral) {
9635
9608
  output.push('LATERAL');
9636
9609
  }
@@ -9644,16 +9617,16 @@ export class Deparser implements DeparserVisitor {
9644
9617
  const nodeType = this.getNodeType(func);
9645
9618
  if (nodeType === 'List') {
9646
9619
  // Handle List containing [FuncCall, List of ColumnDefs]
9647
- const listData = this.getNodeData(func) as any;
9620
+ const listData = this.getNodeData(func);
9648
9621
  if (listData && listData.items && Array.isArray(listData.items)) {
9649
9622
  const items = listData.items;
9650
9623
  if (items.length >= 2) {
9651
9624
  const funcCall = this.visit(items[0], context);
9652
- const coldefList = this.getNodeData(items[1]) as any;
9625
+ const coldefList = this.getNodeData(items[1]);
9653
9626
  if (coldefList && coldefList.items && Array.isArray(coldefList.items)) {
9654
9627
  const coldefs = coldefList.items
9655
- .map((coldef: any) => this.visit(coldef, context))
9656
- .filter((str: string) => str && str.trim());
9628
+ .map((coldef) => this.visit(coldef, context))
9629
+ .filter((str) => str && str.trim());
9657
9630
  if (coldefs.length > 0) {
9658
9631
  return `${funcCall} AS (${coldefs.join(', ')})`;
9659
9632
  }
@@ -9687,7 +9660,7 @@ export class Deparser implements DeparserVisitor {
9687
9660
  const nodeType = this.getNodeType(func);
9688
9661
  if (nodeType === 'List') {
9689
9662
  // Handle List containing [FuncCall, potentially empty second item]
9690
- const listData = this.getNodeData(func) as any;
9663
+ const listData = this.getNodeData(func);
9691
9664
  if (listData && listData.items && Array.isArray(listData.items)) {
9692
9665
  const items = listData.items;
9693
9666
  if (items.length >= 1) {
@@ -9733,7 +9706,7 @@ export class Deparser implements DeparserVisitor {
9733
9706
  }
9734
9707
  return output.join(' ');
9735
9708
  }
9736
- XmlExpr(node: any, context: DeparserContext): string {
9709
+ XmlExpr(node, context) {
9737
9710
  // Handle XMLPI with special syntax: xmlpi(name target, content)
9738
9711
  if (node.op === 'IS_XMLPI') {
9739
9712
  if (node.name && node.args && node.args.length > 0) {
@@ -9747,14 +9720,14 @@ export class Deparser implements DeparserVisitor {
9747
9720
  return 'XMLPI()';
9748
9721
  }
9749
9722
  }
9750
- const output: string[] = [];
9723
+ const output = [];
9751
9724
  switch (node.op) {
9752
9725
  case 'IS_XMLCONCAT':
9753
9726
  output.push('XMLCONCAT');
9754
9727
  break;
9755
9728
  case 'IS_XMLELEMENT':
9756
9729
  output.push('XMLELEMENT');
9757
- const elementParts: string[] = [];
9730
+ const elementParts = [];
9758
9731
  if (node.name) {
9759
9732
  elementParts.push(`NAME ${QuoteUtils.quote(node.name)}`);
9760
9733
  }
@@ -9775,7 +9748,7 @@ export class Deparser implements DeparserVisitor {
9775
9748
  break;
9776
9749
  case 'IS_XMLPARSE':
9777
9750
  output.push('XMLPARSE');
9778
- const parseParts: string[] = [];
9751
+ const parseParts = [];
9779
9752
  if (node.xmloption) {
9780
9753
  if (node.xmloption === 'XMLOPTION_DOCUMENT') {
9781
9754
  parseParts.push('DOCUMENT');
@@ -9798,7 +9771,7 @@ export class Deparser implements DeparserVisitor {
9798
9771
  output.push('XMLROOT');
9799
9772
  if (node.args && node.args.length > 0) {
9800
9773
  const args = ListUtils.unwrapList(node.args);
9801
- const rootParts: string[] = [];
9774
+ const rootParts = [];
9802
9775
  if (args[0]) {
9803
9776
  rootParts.push(this.visit(args[0], context));
9804
9777
  }
@@ -9875,7 +9848,7 @@ export class Deparser implements DeparserVisitor {
9875
9848
  }
9876
9849
  return output.join(' ');
9877
9850
  }
9878
- schemaname(node: any, context: DeparserContext): string {
9851
+ schemaname(node, context) {
9879
9852
  if (typeof node === 'string') {
9880
9853
  return QuoteUtils.quote(node);
9881
9854
  }
@@ -9902,28 +9875,28 @@ export class Deparser implements DeparserVisitor {
9902
9875
  }
9903
9876
  return '';
9904
9877
  }
9905
- RangeTableSample(node: any, context: DeparserContext): string {
9906
- const output: string[] = [];
9878
+ RangeTableSample(node, context) {
9879
+ const output = [];
9907
9880
  if (node.relation) {
9908
- output.push(this.visit(node.relation as any, context));
9881
+ output.push(this.visit(node.relation, context));
9909
9882
  }
9910
9883
  output.push('TABLESAMPLE');
9911
9884
  if (node.method && node.method.length > 0) {
9912
- const methodParts = node.method.map((m: any) => this.visit(m, context));
9885
+ const methodParts = node.method.map((m) => this.visit(m, context));
9913
9886
  output.push(methodParts.join('.'));
9914
9887
  }
9915
9888
  if (node.args && node.args.length > 0) {
9916
- const argStrs = node.args.map((arg: any) => this.visit(arg, context));
9889
+ const argStrs = node.args.map((arg) => this.visit(arg, context));
9917
9890
  output.push(`(${argStrs.join(', ')})`);
9918
9891
  }
9919
9892
  if (node.repeatable) {
9920
9893
  output.push('REPEATABLE');
9921
- output.push(`(${this.visit(node.repeatable as any, context)})`);
9894
+ output.push(`(${this.visit(node.repeatable, context)})`);
9922
9895
  }
9923
9896
  return output.join(' ');
9924
9897
  }
9925
- XmlSerialize(node: any, context: DeparserContext): string {
9926
- const output: string[] = ['XMLSERIALIZE'];
9898
+ XmlSerialize(node, context) {
9899
+ const output = ['XMLSERIALIZE'];
9927
9900
  output.push('(');
9928
9901
  if (node.typeName) {
9929
9902
  if (node.xmloption === 'XMLOPTION_DOCUMENT') {
@@ -9932,18 +9905,18 @@ export class Deparser implements DeparserVisitor {
9932
9905
  else {
9933
9906
  output.push('CONTENT');
9934
9907
  }
9935
- output.push(this.visit(node.expr as any, context));
9908
+ output.push(this.visit(node.expr, context));
9936
9909
  output.push('AS');
9937
9910
  output.push(this.TypeName(node.typeName, context));
9938
9911
  }
9939
9912
  output.push(')');
9940
9913
  return output.join(' ');
9941
9914
  }
9942
- ctes(node: any, context: DeparserContext): string {
9915
+ ctes(node, context) {
9943
9916
  if (!node || !Array.isArray(node)) {
9944
9917
  return '';
9945
9918
  }
9946
- const output: string[] = ['WITH'];
9919
+ const output = ['WITH'];
9947
9920
  // Check if any CTE is recursive by examining the first CTE's structure
9948
9921
  if (node.length > 0 && node[0] && node[0].CommonTableExpr && node[0].CommonTableExpr.recursive) {
9949
9922
  output.push('RECURSIVE');
@@ -9952,8 +9925,8 @@ export class Deparser implements DeparserVisitor {
9952
9925
  output.push(cteStrs.join(', '));
9953
9926
  return output.join(' ');
9954
9927
  }
9955
- RuleStmt(node: any, context: DeparserContext): string {
9956
- const output: string[] = ['CREATE'];
9928
+ RuleStmt(node, context) {
9929
+ const output = ['CREATE'];
9957
9930
  if (node.replace) {
9958
9931
  output.push('OR REPLACE');
9959
9932
  }
@@ -9983,7 +9956,7 @@ export class Deparser implements DeparserVisitor {
9983
9956
  output.push('TO');
9984
9957
  if (node.relation) {
9985
9958
  // Handle relation node directly as RangeVar since it contains the RangeVar properties
9986
- output.push(this.RangeVar(node.relation as any, context));
9959
+ output.push(this.RangeVar(node.relation, context));
9987
9960
  }
9988
9961
  if (node.whereClause) {
9989
9962
  output.push('WHERE');
@@ -10009,8 +9982,8 @@ export class Deparser implements DeparserVisitor {
10009
9982
  }
10010
9983
  return output.join(' ');
10011
9984
  }
10012
- RangeSubselect(node: any, context: DeparserContext): string {
10013
- const output: string[] = [];
9985
+ RangeSubselect(node, context) {
9986
+ const output = [];
10014
9987
  if (node.lateral) {
10015
9988
  output.push('LATERAL');
10016
9989
  }
@@ -10024,7 +9997,7 @@ export class Deparser implements DeparserVisitor {
10024
9997
  }
10025
9998
  return output.join(' ');
10026
9999
  }
10027
- relname(node: any, context: DeparserContext): string {
10000
+ relname(node, context) {
10028
10001
  if (typeof node === 'string') {
10029
10002
  return QuoteUtils.quote(node);
10030
10003
  }
@@ -10036,7 +10009,7 @@ export class Deparser implements DeparserVisitor {
10036
10009
  }
10037
10010
  return this.visit(node, context);
10038
10011
  }
10039
- rel(node: any, context: DeparserContext): string {
10012
+ rel(node, context) {
10040
10013
  if (typeof node === 'string') {
10041
10014
  return QuoteUtils.quote(node);
10042
10015
  }
@@ -10051,7 +10024,7 @@ export class Deparser implements DeparserVisitor {
10051
10024
  }
10052
10025
  return this.visit(node, context);
10053
10026
  }
10054
- objname(node: any, context: DeparserContext): string {
10027
+ objname(node, context) {
10055
10028
  if (typeof node === 'string') {
10056
10029
  return QuoteUtils.quote(node);
10057
10030
  }
@@ -10069,7 +10042,7 @@ export class Deparser implements DeparserVisitor {
10069
10042
  }
10070
10043
  return this.visit(node, context);
10071
10044
  }
10072
- SQLValueFunction(node: any, context: DeparserContext): string {
10045
+ SQLValueFunction(node, context) {
10073
10046
  switch (node.op) {
10074
10047
  case 'SVFOP_CURRENT_DATE':
10075
10048
  return 'CURRENT_DATE';
@@ -10105,8 +10078,8 @@ export class Deparser implements DeparserVisitor {
10105
10078
  throw new Error(`Unsupported SQLValueFunction op: ${node.op}`);
10106
10079
  }
10107
10080
  }
10108
- GroupingFunc(node: any, context: DeparserContext): string {
10109
- const output: string[] = ['GROUPING'];
10081
+ GroupingFunc(node, context) {
10082
+ const output = ['GROUPING'];
10110
10083
  if (node.args && node.args.length > 0) {
10111
10084
  const argStrs = ListUtils.unwrapList(node.args).map(arg => this.visit(arg, context));
10112
10085
  output.push(`(${argStrs.join(', ')})`);
@@ -10116,8 +10089,8 @@ export class Deparser implements DeparserVisitor {
10116
10089
  }
10117
10090
  return output.join('');
10118
10091
  }
10119
- MultiAssignRef(node: any, context: DeparserContext): string {
10120
- const output: string[] = [];
10092
+ MultiAssignRef(node, context) {
10093
+ const output = [];
10121
10094
  if (node.source) {
10122
10095
  output.push(this.visit(node.source, context));
10123
10096
  }
@@ -10126,11 +10099,11 @@ export class Deparser implements DeparserVisitor {
10126
10099
  }
10127
10100
  return output.join('');
10128
10101
  }
10129
- SetToDefault(node: any, context: DeparserContext): string {
10102
+ SetToDefault(node, context) {
10130
10103
  return 'DEFAULT';
10131
10104
  }
10132
- CurrentOfExpr(node: any, context: DeparserContext): string {
10133
- const output: string[] = ['CURRENT OF'];
10105
+ CurrentOfExpr(node, context) {
10106
+ const output = ['CURRENT OF'];
10134
10107
  if (node.cursor_name) {
10135
10108
  output.push(QuoteUtils.quote(node.cursor_name));
10136
10109
  }
@@ -10139,10 +10112,10 @@ export class Deparser implements DeparserVisitor {
10139
10112
  }
10140
10113
  return output.join(' ');
10141
10114
  }
10142
- TableLikeClause(node: any, context: DeparserContext): string {
10143
- const output: string[] = ['LIKE'];
10115
+ TableLikeClause(node, context) {
10116
+ const output = ['LIKE'];
10144
10117
  if (node.relation) {
10145
- output.push(this.visit(node.relation as any, context));
10118
+ output.push(this.visit(node.relation, context));
10146
10119
  }
10147
10120
  if (node.options && typeof node.options === 'number') {
10148
10121
  // Handle special case for INCLUDING ALL (all bits set)
@@ -10150,7 +10123,7 @@ export class Deparser implements DeparserVisitor {
10150
10123
  output.push('INCLUDING ALL');
10151
10124
  }
10152
10125
  else {
10153
- const optionStrs: string[] = [];
10126
+ const optionStrs = [];
10154
10127
  // Handle bitfield options for CREATE TABLE LIKE
10155
10128
  if (node.options & 0x01)
10156
10129
  optionStrs.push('INCLUDING COMMENTS');
@@ -10175,8 +10148,8 @@ export class Deparser implements DeparserVisitor {
10175
10148
  }
10176
10149
  return output.join(' ');
10177
10150
  }
10178
- AlterFunctionStmt(node: any, context: DeparserContext): string {
10179
- const output: string[] = ['ALTER'];
10151
+ AlterFunctionStmt(node, context) {
10152
+ const output = ['ALTER'];
10180
10153
  if (node.objtype === 'OBJECT_PROCEDURE') {
10181
10154
  output.push('PROCEDURE');
10182
10155
  }
@@ -10193,8 +10166,8 @@ export class Deparser implements DeparserVisitor {
10193
10166
  }
10194
10167
  return output.join(' ');
10195
10168
  }
10196
- AlterObjectSchemaStmt(node: any, context: DeparserContext): string {
10197
- const output: string[] = ['ALTER'];
10169
+ AlterObjectSchemaStmt(node, context) {
10170
+ const output = ['ALTER'];
10198
10171
  switch (node.objectType) {
10199
10172
  case 'OBJECT_TABLE':
10200
10173
  output.push('TABLE');
@@ -10264,92 +10237,92 @@ export class Deparser implements DeparserVisitor {
10264
10237
  }
10265
10238
  else if (node.object) {
10266
10239
  // Handle domain objects specially to format schema.domain correctly
10267
- if (node.objectType === 'OBJECT_DOMAIN' && (node.object as any).List) {
10268
- const items = ListUtils.unwrapList(node.object as any);
10240
+ if (node.objectType === 'OBJECT_DOMAIN' && node.object.List) {
10241
+ const items = ListUtils.unwrapList(node.object);
10269
10242
  if (items.length === 2) {
10270
10243
  const schemaName = items[0].String?.sval || '';
10271
10244
  const domainName = items[1].String?.sval || '';
10272
10245
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(domainName)}`);
10273
10246
  }
10274
10247
  else {
10275
- output.push(this.visit(node.object as any, context));
10248
+ output.push(this.visit(node.object, context));
10276
10249
  }
10277
10250
  }
10278
- else if (node.objectType === 'OBJECT_TYPE' && (node.object as any).List) {
10251
+ else if (node.objectType === 'OBJECT_TYPE' && node.object.List) {
10279
10252
  // Handle type objects specially to format schema.type correctly
10280
- const items = ListUtils.unwrapList(node.object as any);
10253
+ const items = ListUtils.unwrapList(node.object);
10281
10254
  if (items.length === 2) {
10282
10255
  const schemaName = items[0].String?.sval || '';
10283
10256
  const typeName = items[1].String?.sval || '';
10284
10257
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(typeName)}`);
10285
10258
  }
10286
10259
  else {
10287
- output.push(this.visit(node.object as any, context));
10260
+ output.push(this.visit(node.object, context));
10288
10261
  }
10289
10262
  }
10290
- else if (node.objectType === 'OBJECT_CONVERSION' && (node.object as any).List) {
10263
+ else if (node.objectType === 'OBJECT_CONVERSION' && node.object.List) {
10291
10264
  // Handle conversion objects specially to format schema.conversion correctly
10292
- const items = ListUtils.unwrapList(node.object as any);
10265
+ const items = ListUtils.unwrapList(node.object);
10293
10266
  if (items.length === 2) {
10294
10267
  const schemaName = items[0].String?.sval || '';
10295
10268
  const conversionName = items[1].String?.sval || '';
10296
10269
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(conversionName)}`);
10297
10270
  }
10298
10271
  else {
10299
- output.push(this.visit(node.object as any, context));
10272
+ output.push(this.visit(node.object, context));
10300
10273
  }
10301
10274
  }
10302
- else if (node.objectType === 'OBJECT_TSPARSER' && (node.object as any).List) {
10275
+ else if (node.objectType === 'OBJECT_TSPARSER' && node.object.List) {
10303
10276
  // Handle text search parser objects specially to format schema.parser correctly
10304
- const items = ListUtils.unwrapList(node.object as any);
10277
+ const items = ListUtils.unwrapList(node.object);
10305
10278
  if (items.length === 2) {
10306
10279
  const schemaName = items[0].String?.sval || '';
10307
10280
  const parserName = items[1].String?.sval || '';
10308
10281
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(parserName)}`);
10309
10282
  }
10310
10283
  else {
10311
- output.push(this.visit(node.object as any, context));
10284
+ output.push(this.visit(node.object, context));
10312
10285
  }
10313
10286
  }
10314
- else if (node.objectType === 'OBJECT_TSCONFIGURATION' && (node.object as any).List) {
10287
+ else if (node.objectType === 'OBJECT_TSCONFIGURATION' && node.object.List) {
10315
10288
  // Handle text search configuration objects specially to format schema.config correctly
10316
- const items = ListUtils.unwrapList(node.object as any);
10289
+ const items = ListUtils.unwrapList(node.object);
10317
10290
  if (items.length === 2) {
10318
10291
  const schemaName = items[0].String?.sval || '';
10319
10292
  const configName = items[1].String?.sval || '';
10320
10293
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(configName)}`);
10321
10294
  }
10322
10295
  else {
10323
- output.push(this.visit(node.object as any, context));
10296
+ output.push(this.visit(node.object, context));
10324
10297
  }
10325
10298
  }
10326
- else if (node.objectType === 'OBJECT_TSTEMPLATE' && (node.object as any).List) {
10299
+ else if (node.objectType === 'OBJECT_TSTEMPLATE' && node.object.List) {
10327
10300
  // Handle text search template objects specially to format schema.template correctly
10328
- const items = ListUtils.unwrapList(node.object as any);
10301
+ const items = ListUtils.unwrapList(node.object);
10329
10302
  if (items.length === 2) {
10330
10303
  const schemaName = items[0].String?.sval || '';
10331
10304
  const templateName = items[1].String?.sval || '';
10332
10305
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(templateName)}`);
10333
10306
  }
10334
10307
  else {
10335
- output.push(this.visit(node.object as any, context));
10308
+ output.push(this.visit(node.object, context));
10336
10309
  }
10337
10310
  }
10338
- else if (node.objectType === 'OBJECT_TSDICTIONARY' && (node.object as any).List) {
10311
+ else if (node.objectType === 'OBJECT_TSDICTIONARY' && node.object.List) {
10339
10312
  // Handle text search dictionary objects specially to format schema.dictionary correctly
10340
- const items = ListUtils.unwrapList(node.object as any);
10313
+ const items = ListUtils.unwrapList(node.object);
10341
10314
  if (items.length === 2) {
10342
10315
  const schemaName = items[0].String?.sval || '';
10343
10316
  const dictionaryName = items[1].String?.sval || '';
10344
10317
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(dictionaryName)}`);
10345
10318
  }
10346
10319
  else {
10347
- output.push(this.visit(node.object as any, context));
10320
+ output.push(this.visit(node.object, context));
10348
10321
  }
10349
10322
  }
10350
- else if (node.objectType === 'OBJECT_OPCLASS' && (node.object as any).List) {
10323
+ else if (node.objectType === 'OBJECT_OPCLASS' && node.object.List) {
10351
10324
  // Handle operator class objects: ALTER OPERATOR CLASS name USING access_method
10352
- const items = ListUtils.unwrapList(node.object as any);
10325
+ const items = ListUtils.unwrapList(node.object);
10353
10326
  if (items.length === 2) {
10354
10327
  const accessMethod = items[0].String?.sval || '';
10355
10328
  const opClassName = items[1].String?.sval || '';
@@ -10362,12 +10335,12 @@ export class Deparser implements DeparserVisitor {
10362
10335
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(opClassName)} USING ${accessMethod}`);
10363
10336
  }
10364
10337
  else {
10365
- output.push(this.visit(node.object as any, context));
10338
+ output.push(this.visit(node.object, context));
10366
10339
  }
10367
10340
  }
10368
- else if (node.objectType === 'OBJECT_OPFAMILY' && (node.object as any).List) {
10341
+ else if (node.objectType === 'OBJECT_OPFAMILY' && node.object.List) {
10369
10342
  // Handle operator family objects: ALTER OPERATOR FAMILY name USING access_method
10370
- const items = ListUtils.unwrapList(node.object as any);
10343
+ const items = ListUtils.unwrapList(node.object);
10371
10344
  if (items.length === 2) {
10372
10345
  const accessMethod = items[0].String?.sval || '';
10373
10346
  const opFamilyName = items[1].String?.sval || '';
@@ -10380,11 +10353,11 @@ export class Deparser implements DeparserVisitor {
10380
10353
  output.push(`${QuoteUtils.quote(schemaName)}.${QuoteUtils.quote(opFamilyName)} USING ${accessMethod}`);
10381
10354
  }
10382
10355
  else {
10383
- output.push(this.visit(node.object as any, context));
10356
+ output.push(this.visit(node.object, context));
10384
10357
  }
10385
10358
  }
10386
10359
  else {
10387
- output.push(this.visit(node.object as any, context));
10360
+ output.push(this.visit(node.object, context));
10388
10361
  }
10389
10362
  }
10390
10363
  output.push('SET SCHEMA');
@@ -10393,8 +10366,8 @@ export class Deparser implements DeparserVisitor {
10393
10366
  }
10394
10367
  return output.join(' ');
10395
10368
  }
10396
- AlterRoleSetStmt(node: any, context: DeparserContext): string {
10397
- const output: string[] = ['ALTER', 'ROLE'];
10369
+ AlterRoleSetStmt(node, context) {
10370
+ const output = ['ALTER', 'ROLE'];
10398
10371
  if (node.role) {
10399
10372
  output.push(this.RoleSpec(node.role, context));
10400
10373
  }
@@ -10428,12 +10401,12 @@ export class Deparser implements DeparserVisitor {
10428
10401
  }
10429
10402
  return output.join(' ');
10430
10403
  }
10431
- CreateForeignTableStmt(node: any, context: DeparserContext): string {
10432
- const output: string[] = ['CREATE FOREIGN TABLE'];
10404
+ CreateForeignTableStmt(node, context) {
10405
+ const output = ['CREATE FOREIGN TABLE'];
10433
10406
  if (node.base && node.base.relation) {
10434
10407
  const relationContext = context.spawn('CreateForeignTableStmt');
10435
10408
  // Handle relation node directly as RangeVar since it contains the RangeVar properties
10436
- output.push(this.RangeVar(node.base.relation as any, relationContext));
10409
+ output.push(this.RangeVar(node.base.relation, relationContext));
10437
10410
  }
10438
10411
  if (node.base && node.base.tableElts) {
10439
10412
  const elementStrs = ListUtils.unwrapList(node.base.tableElts).map(el => this.visit(el, context));
@@ -10467,7 +10440,7 @@ export class Deparser implements DeparserVisitor {
10467
10440
  }
10468
10441
  return output.join(' ');
10469
10442
  }
10470
- private containsMultilineStringLiteral(content: string): boolean {
10443
+ containsMultilineStringLiteral(content) {
10471
10444
  const stringLiteralRegex = /'[^']*\n[^']*'/g;
10472
10445
  return stringLiteralRegex.test(content);
10473
10446
  }