pgsql-deparser 17.18.2 → 17.18.3

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
@@ -1317,8 +1317,13 @@ class Deparser {
1317
1317
  }
1318
1318
  // Handle EXTRACT function with SQL syntax
1319
1319
  if (node.funcformat === 'COERCE_SQL_SYNTAX' && name === 'pg_catalog.extract' && args.length >= 2) {
1320
- const field = this.visit(args[0], context);
1320
+ let field = this.visit(args[0], context);
1321
1321
  const source = this.visit(args[1], context);
1322
+ // EXTRACT requires an unquoted uppercase keyword (EPOCH, YEAR, etc.)
1323
+ // but A_Const sval deparsing wraps it in single quotes — strip and uppercase
1324
+ if (field.startsWith("'") && field.endsWith("'")) {
1325
+ field = field.slice(1, -1).toUpperCase();
1326
+ }
1322
1327
  return `EXTRACT(${field} FROM ${source})`;
1323
1328
  }
1324
1329
  // Handle TRIM function with SQL syntax (TRIM TRAILING/LEADING/BOTH)
package/esm/deparser.js CHANGED
@@ -1314,8 +1314,13 @@ export class Deparser {
1314
1314
  }
1315
1315
  // Handle EXTRACT function with SQL syntax
1316
1316
  if (node.funcformat === 'COERCE_SQL_SYNTAX' && name === 'pg_catalog.extract' && args.length >= 2) {
1317
- const field = this.visit(args[0], context);
1317
+ let field = this.visit(args[0], context);
1318
1318
  const source = this.visit(args[1], context);
1319
+ // EXTRACT requires an unquoted uppercase keyword (EPOCH, YEAR, etc.)
1320
+ // but A_Const sval deparsing wraps it in single quotes — strip and uppercase
1321
+ if (field.startsWith("'") && field.endsWith("'")) {
1322
+ field = field.slice(1, -1).toUpperCase();
1323
+ }
1319
1324
  return `EXTRACT(${field} FROM ${source})`;
1320
1325
  }
1321
1326
  // Handle TRIM function with SQL syntax (TRIM TRAILING/LEADING/BOTH)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "17.18.2",
3
+ "version": "17.18.3",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL AST Deparser",
6
6
  "main": "index.js",
@@ -60,5 +60,5 @@
60
60
  "@pgsql/quotes": "17.1.0",
61
61
  "@pgsql/types": "^17.6.2"
62
62
  },
63
- "gitHead": "cdd732b4694b84522895d2d1dd8d5db9944875d5"
63
+ "gitHead": "16d4dced1144372f2debc270ea07e9d842cc50c9"
64
64
  }