pgsql-deparser 17.15.2 → 17.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/deparser.js CHANGED
@@ -508,7 +508,9 @@ class Deparser {
508
508
  output.push('VALUES');
509
509
  const lists = list_utils_1.ListUtils.unwrapList(node.valuesLists).map(list => {
510
510
  const values = list_utils_1.ListUtils.unwrapList(list).map(val => this.visit(val, context));
511
- return context.parens(values.join(', '));
511
+ // Put each value on its own line for pretty printing
512
+ const indentedValues = values.map(val => context.indent(val));
513
+ return '(\n' + indentedValues.join(',\n') + '\n)';
512
514
  });
513
515
  const indentedTuples = lists.map(tuple => {
514
516
  if (this.containsMultilineStringLiteral(tuple)) {
@@ -1021,7 +1023,14 @@ class Deparser {
1021
1023
  else {
1022
1024
  const updateContext = context.spawn('UpdateStmt', { update: true });
1023
1025
  const targets = targetList.map(target => this.visit(target, updateContext));
1024
- output.push(targets.join(', '));
1026
+ if (context.isPretty()) {
1027
+ // Put each assignment on its own line for pretty printing
1028
+ const indentedTargets = targets.map(target => context.indent(target));
1029
+ output.push('\n' + indentedTargets.join(',\n'));
1030
+ }
1031
+ else {
1032
+ output.push(targets.join(', '));
1033
+ }
1025
1034
  }
1026
1035
  }
1027
1036
  if (node.onConflictClause.whereClause) {
@@ -2055,7 +2064,7 @@ class Deparser {
2055
2064
  if (size != null) {
2056
2065
  return 'char';
2057
2066
  }
2058
- return 'pg_catalog.bpchar';
2067
+ return 'bpchar';
2059
2068
  case 'varchar':
2060
2069
  return 'varchar';
2061
2070
  case 'numeric':
@@ -2069,7 +2078,7 @@ class Deparser {
2069
2078
  case 'int8':
2070
2079
  return 'bigint';
2071
2080
  case 'real':
2072
- return 'pg_catalog.float4';
2081
+ return 'float4';
2073
2082
  case 'time':
2074
2083
  return 'time';
2075
2084
  case 'timestamp':
@@ -2079,7 +2088,7 @@ class Deparser {
2079
2088
  case 'bit':
2080
2089
  return 'bit';
2081
2090
  default:
2082
- return `pg_catalog.${typeName}`;
2091
+ return typeName;
2083
2092
  }
2084
2093
  }
2085
2094
  isPgCatalogType(typeName) {
@@ -5170,7 +5179,13 @@ class Deparser {
5170
5179
  })
5171
5180
  .map((param) => this.visit(param, context));
5172
5181
  if (params.length > 0) {
5173
- output.push(funcName + '(' + params.join(', ') + ')');
5182
+ if (context.isPretty()) {
5183
+ const formattedParams = params.map(p => context.indent(p)).join(',' + context.newline());
5184
+ output.push(funcName + '(' + context.newline() + formattedParams + context.newline() + ')');
5185
+ }
5186
+ else {
5187
+ output.push(funcName + '(' + params.join(', ') + ')');
5188
+ }
5174
5189
  }
5175
5190
  else {
5176
5191
  output.push(funcName + '()');
@@ -5185,15 +5200,21 @@ class Deparser {
5185
5200
  return paramData.mode === 'FUNC_PARAM_TABLE';
5186
5201
  });
5187
5202
  if (hasTableParams) {
5188
- output.push('RETURNS TABLE (');
5189
5203
  const tableParams = node.parameters
5190
5204
  .filter((param) => {
5191
5205
  const paramData = this.getNodeData(param);
5192
5206
  return paramData.mode === 'FUNC_PARAM_TABLE';
5193
5207
  })
5194
5208
  .map((param) => this.visit(param, context));
5195
- output.push(tableParams.join(', '));
5196
- output.push(')');
5209
+ if (context.isPretty()) {
5210
+ const formattedTableParams = tableParams.map(p => context.indent(p)).join(',' + context.newline());
5211
+ output.push('RETURNS TABLE (' + context.newline() + formattedTableParams + context.newline() + ')');
5212
+ }
5213
+ else {
5214
+ output.push('RETURNS TABLE (');
5215
+ output.push(tableParams.join(', '));
5216
+ output.push(')');
5217
+ }
5197
5218
  }
5198
5219
  else if (node.returnType) {
5199
5220
  output.push('RETURNS');
package/esm/deparser.js CHANGED
@@ -505,7 +505,9 @@ export class Deparser {
505
505
  output.push('VALUES');
506
506
  const lists = ListUtils.unwrapList(node.valuesLists).map(list => {
507
507
  const values = ListUtils.unwrapList(list).map(val => this.visit(val, context));
508
- return context.parens(values.join(', '));
508
+ // Put each value on its own line for pretty printing
509
+ const indentedValues = values.map(val => context.indent(val));
510
+ return '(\n' + indentedValues.join(',\n') + '\n)';
509
511
  });
510
512
  const indentedTuples = lists.map(tuple => {
511
513
  if (this.containsMultilineStringLiteral(tuple)) {
@@ -1018,7 +1020,14 @@ export class Deparser {
1018
1020
  else {
1019
1021
  const updateContext = context.spawn('UpdateStmt', { update: true });
1020
1022
  const targets = targetList.map(target => this.visit(target, updateContext));
1021
- output.push(targets.join(', '));
1023
+ if (context.isPretty()) {
1024
+ // Put each assignment on its own line for pretty printing
1025
+ const indentedTargets = targets.map(target => context.indent(target));
1026
+ output.push('\n' + indentedTargets.join(',\n'));
1027
+ }
1028
+ else {
1029
+ output.push(targets.join(', '));
1030
+ }
1022
1031
  }
1023
1032
  }
1024
1033
  if (node.onConflictClause.whereClause) {
@@ -2052,7 +2061,7 @@ export class Deparser {
2052
2061
  if (size != null) {
2053
2062
  return 'char';
2054
2063
  }
2055
- return 'pg_catalog.bpchar';
2064
+ return 'bpchar';
2056
2065
  case 'varchar':
2057
2066
  return 'varchar';
2058
2067
  case 'numeric':
@@ -2066,7 +2075,7 @@ export class Deparser {
2066
2075
  case 'int8':
2067
2076
  return 'bigint';
2068
2077
  case 'real':
2069
- return 'pg_catalog.float4';
2078
+ return 'float4';
2070
2079
  case 'time':
2071
2080
  return 'time';
2072
2081
  case 'timestamp':
@@ -2076,7 +2085,7 @@ export class Deparser {
2076
2085
  case 'bit':
2077
2086
  return 'bit';
2078
2087
  default:
2079
- return `pg_catalog.${typeName}`;
2088
+ return typeName;
2080
2089
  }
2081
2090
  }
2082
2091
  isPgCatalogType(typeName) {
@@ -5167,7 +5176,13 @@ export class Deparser {
5167
5176
  })
5168
5177
  .map((param) => this.visit(param, context));
5169
5178
  if (params.length > 0) {
5170
- output.push(funcName + '(' + params.join(', ') + ')');
5179
+ if (context.isPretty()) {
5180
+ const formattedParams = params.map(p => context.indent(p)).join(',' + context.newline());
5181
+ output.push(funcName + '(' + context.newline() + formattedParams + context.newline() + ')');
5182
+ }
5183
+ else {
5184
+ output.push(funcName + '(' + params.join(', ') + ')');
5185
+ }
5171
5186
  }
5172
5187
  else {
5173
5188
  output.push(funcName + '()');
@@ -5182,15 +5197,21 @@ export class Deparser {
5182
5197
  return paramData.mode === 'FUNC_PARAM_TABLE';
5183
5198
  });
5184
5199
  if (hasTableParams) {
5185
- output.push('RETURNS TABLE (');
5186
5200
  const tableParams = node.parameters
5187
5201
  .filter((param) => {
5188
5202
  const paramData = this.getNodeData(param);
5189
5203
  return paramData.mode === 'FUNC_PARAM_TABLE';
5190
5204
  })
5191
5205
  .map((param) => this.visit(param, context));
5192
- output.push(tableParams.join(', '));
5193
- output.push(')');
5206
+ if (context.isPretty()) {
5207
+ const formattedTableParams = tableParams.map(p => context.indent(p)).join(',' + context.newline());
5208
+ output.push('RETURNS TABLE (' + context.newline() + formattedTableParams + context.newline() + ')');
5209
+ }
5210
+ else {
5211
+ output.push('RETURNS TABLE (');
5212
+ output.push(tableParams.join(', '));
5213
+ output.push(')');
5214
+ }
5194
5215
  }
5195
5216
  else if (node.returnType) {
5196
5217
  output.push('RETURNS');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "17.15.2",
3
+ "version": "17.17.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL AST Deparser",
6
6
  "main": "index.js",
@@ -60,5 +60,5 @@
60
60
  "dependencies": {
61
61
  "@pgsql/types": "^17.6.2"
62
62
  },
63
- "gitHead": "e5fdba1e3a67157bb5cab8ab40741f6f206d71b3"
63
+ "gitHead": "529f487216d0ca3d93b1dea2e6411a1e5432d183"
64
64
  }