pgsql-deparser 18.2.0 → 18.3.1

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Node } from '@pgsql/types';
2
- import { DeparserContext, DeparserVisitor } from './visitors/base';
3
2
  import * as t from '@pgsql/types';
3
+ import { DeparserContext, DeparserVisitor } from './visitors/base';
4
4
  export interface DeparserOptions {
5
5
  newline?: string;
6
6
  tab?: string;
package/deparser.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Deparser = void 0;
4
- const base_1 = require("./visitors/base");
5
- const sql_formatter_1 = require("./utils/sql-formatter");
6
4
  const quotes_1 = require("@pgsql/quotes");
7
5
  const list_utils_1 = require("./utils/list-utils");
6
+ const sql_formatter_1 = require("./utils/sql-formatter");
7
+ const base_1 = require("./visitors/base");
8
8
  /**
9
9
  * List of real PostgreSQL built-in types as they appear in pg_catalog.pg_type.typname.
10
10
  * These are stored in lowercase in PostgreSQL system catalogs.
@@ -846,15 +846,15 @@ class Deparser {
846
846
  getOperatorPrecedence(operator) {
847
847
  const precedence = {
848
848
  '||': 1, // string concatenation
849
- 'OR': 2, // logical OR
850
- 'AND': 3, // logical AND
851
- 'NOT': 4, // logical NOT
852
- 'IS': 5, // IS NULL, IS NOT NULL, etc.
853
- 'IN': 5, // IN, NOT IN
854
- 'BETWEEN': 5, // BETWEEN, NOT BETWEEN
855
- 'LIKE': 5, // LIKE, ILIKE, SIMILAR TO
856
- 'ILIKE': 5,
857
- 'SIMILAR': 5,
849
+ OR: 2, // logical OR
850
+ AND: 3, // logical AND
851
+ NOT: 4, // logical NOT
852
+ IS: 5, // IS NULL, IS NOT NULL, etc.
853
+ IN: 5, // IN, NOT IN
854
+ BETWEEN: 5, // BETWEEN, NOT BETWEEN
855
+ LIKE: 5, // LIKE, ILIKE, SIMILAR TO
856
+ ILIKE: 5,
857
+ SIMILAR: 5,
858
858
  '<': 6, // comparison operators
859
859
  '<=': 6,
860
860
  '>': 6,
@@ -2331,16 +2331,16 @@ class Deparser {
2331
2331
  }
2332
2332
  preserveOperatorDefElemCase(defName) {
2333
2333
  const caseMap = {
2334
- 'leftarg': 'Leftarg',
2335
- 'rightarg': 'Rightarg',
2336
- 'procedure': 'Procedure',
2337
- 'function': 'Function',
2338
- 'commutator': 'Commutator',
2339
- 'negator': 'Negator',
2340
- 'restrict': 'Restrict',
2341
- 'join': 'Join',
2342
- 'hashes': 'Hashes',
2343
- 'merges': 'Merges'
2334
+ leftarg: 'Leftarg',
2335
+ rightarg: 'Rightarg',
2336
+ procedure: 'Procedure',
2337
+ function: 'Function',
2338
+ commutator: 'Commutator',
2339
+ negator: 'Negator',
2340
+ restrict: 'Restrict',
2341
+ join: 'Join',
2342
+ hashes: 'Hashes',
2343
+ merges: 'Merges'
2344
2344
  };
2345
2345
  return caseMap[defName.toLowerCase()] || defName;
2346
2346
  }
@@ -2576,7 +2576,7 @@ class Deparser {
2576
2576
  Constraint(node, context) {
2577
2577
  const output = [];
2578
2578
  // Handle constraint name if present
2579
- if (node.conname && (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_UNIQUE' || node.contype === 'CONSTR_PRIMARY' || node.contype === 'CONSTR_FOREIGN' || node.contype === 'CONSTR_NOTNULL')) {
2579
+ if (node.conname && (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_UNIQUE' || node.contype === 'CONSTR_PRIMARY' || node.contype === 'CONSTR_FOREIGN' || node.contype === 'CONSTR_NOTNULL' || node.contype === 'CONSTR_EXCLUSION')) {
2580
2580
  output.push('CONSTRAINT');
2581
2581
  output.push(quotes_1.QuoteUtils.quoteIdentifier(node.conname));
2582
2582
  }
@@ -5339,6 +5339,7 @@ class Deparser {
5339
5339
  if (bodyType === 'List') {
5340
5340
  const statements = list_utils_1.ListUtils.unwrapList(node.sql_body);
5341
5341
  if (statements.length === 0 || (statements.length === 1 && Object.keys(statements[0]).length === 0)) {
5342
+ // empty body: nothing to emit
5342
5343
  }
5343
5344
  else {
5344
5345
  // Handle nested List structure in BEGIN ATOMIC blocks
@@ -10047,6 +10048,7 @@ class Deparser {
10047
10048
  rootParts.push('STANDALONE NO VALUE');
10048
10049
  }
10049
10050
  else if (standaloneArg.A_Const.ival.ival === 3) {
10051
+ // STANDALONE omitted
10050
10052
  }
10051
10053
  else if (Object.keys(standaloneArg.A_Const.ival).length === 0) {
10052
10054
  rootParts.push('STANDALONE YES');
package/esm/deparser.js CHANGED
@@ -1,7 +1,7 @@
1
- import { DeparserContext } from './visitors/base';
2
- import { SqlFormatter } from './utils/sql-formatter';
3
1
  import { QuoteUtils } from '@pgsql/quotes';
4
2
  import { ListUtils } from './utils/list-utils';
3
+ import { SqlFormatter } from './utils/sql-formatter';
4
+ import { DeparserContext } from './visitors/base';
5
5
  /**
6
6
  * List of real PostgreSQL built-in types as they appear in pg_catalog.pg_type.typname.
7
7
  * These are stored in lowercase in PostgreSQL system catalogs.
@@ -843,15 +843,15 @@ export class Deparser {
843
843
  getOperatorPrecedence(operator) {
844
844
  const precedence = {
845
845
  '||': 1, // string concatenation
846
- 'OR': 2, // logical OR
847
- 'AND': 3, // logical AND
848
- 'NOT': 4, // logical NOT
849
- 'IS': 5, // IS NULL, IS NOT NULL, etc.
850
- 'IN': 5, // IN, NOT IN
851
- 'BETWEEN': 5, // BETWEEN, NOT BETWEEN
852
- 'LIKE': 5, // LIKE, ILIKE, SIMILAR TO
853
- 'ILIKE': 5,
854
- 'SIMILAR': 5,
846
+ OR: 2, // logical OR
847
+ AND: 3, // logical AND
848
+ NOT: 4, // logical NOT
849
+ IS: 5, // IS NULL, IS NOT NULL, etc.
850
+ IN: 5, // IN, NOT IN
851
+ BETWEEN: 5, // BETWEEN, NOT BETWEEN
852
+ LIKE: 5, // LIKE, ILIKE, SIMILAR TO
853
+ ILIKE: 5,
854
+ SIMILAR: 5,
855
855
  '<': 6, // comparison operators
856
856
  '<=': 6,
857
857
  '>': 6,
@@ -2328,16 +2328,16 @@ export class Deparser {
2328
2328
  }
2329
2329
  preserveOperatorDefElemCase(defName) {
2330
2330
  const caseMap = {
2331
- 'leftarg': 'Leftarg',
2332
- 'rightarg': 'Rightarg',
2333
- 'procedure': 'Procedure',
2334
- 'function': 'Function',
2335
- 'commutator': 'Commutator',
2336
- 'negator': 'Negator',
2337
- 'restrict': 'Restrict',
2338
- 'join': 'Join',
2339
- 'hashes': 'Hashes',
2340
- 'merges': 'Merges'
2331
+ leftarg: 'Leftarg',
2332
+ rightarg: 'Rightarg',
2333
+ procedure: 'Procedure',
2334
+ function: 'Function',
2335
+ commutator: 'Commutator',
2336
+ negator: 'Negator',
2337
+ restrict: 'Restrict',
2338
+ join: 'Join',
2339
+ hashes: 'Hashes',
2340
+ merges: 'Merges'
2341
2341
  };
2342
2342
  return caseMap[defName.toLowerCase()] || defName;
2343
2343
  }
@@ -2573,7 +2573,7 @@ export class Deparser {
2573
2573
  Constraint(node, context) {
2574
2574
  const output = [];
2575
2575
  // Handle constraint name if present
2576
- if (node.conname && (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_UNIQUE' || node.contype === 'CONSTR_PRIMARY' || node.contype === 'CONSTR_FOREIGN' || node.contype === 'CONSTR_NOTNULL')) {
2576
+ if (node.conname && (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_UNIQUE' || node.contype === 'CONSTR_PRIMARY' || node.contype === 'CONSTR_FOREIGN' || node.contype === 'CONSTR_NOTNULL' || node.contype === 'CONSTR_EXCLUSION')) {
2577
2577
  output.push('CONSTRAINT');
2578
2578
  output.push(QuoteUtils.quoteIdentifier(node.conname));
2579
2579
  }
@@ -5336,6 +5336,7 @@ export class Deparser {
5336
5336
  if (bodyType === 'List') {
5337
5337
  const statements = ListUtils.unwrapList(node.sql_body);
5338
5338
  if (statements.length === 0 || (statements.length === 1 && Object.keys(statements[0]).length === 0)) {
5339
+ // empty body: nothing to emit
5339
5340
  }
5340
5341
  else {
5341
5342
  // Handle nested List structure in BEGIN ATOMIC blocks
@@ -10044,6 +10045,7 @@ export class Deparser {
10044
10045
  rootParts.push('STANDALONE NO VALUE');
10045
10046
  }
10046
10047
  else if (standaloneArg.A_Const.ival.ival === 3) {
10048
+ // STANDALONE omitted
10047
10049
  }
10048
10050
  else if (Object.keys(standaloneArg.A_Const.ival).length === 0) {
10049
10051
  rootParts.push('STANDALONE YES');
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Deparser } from "./deparser";
1
+ import { Deparser } from './deparser';
2
2
  const deparseMethod = Deparser.deparse;
3
3
  // Export the original sync version as deparseSync
4
4
  export const deparseSync = deparseMethod;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Deparser, DeparserOptions } from "./deparser";
1
+ import { Deparser, DeparserOptions } from './deparser';
2
2
  declare const deparseMethod: typeof Deparser.deparse;
3
3
  export declare const deparseSync: typeof Deparser.deparse;
4
4
  export declare const deparse: (...args: Parameters<typeof deparseMethod>) => Promise<ReturnType<typeof deparseMethod>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "18.2.0",
3
+ "version": "18.3.1",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL AST Deparser",
6
6
  "main": "index.js",
@@ -57,8 +57,8 @@
57
57
  "makage": "^0.1.8"
58
58
  },
59
59
  "dependencies": {
60
- "@pgsql/quotes": "18.1.0",
60
+ "@pgsql/quotes": "18.2.0",
61
61
  "@pgsql/types": "^18.0.0"
62
62
  },
63
- "gitHead": "884ba252cf8b074c6790b3722477acc3d6f92539"
63
+ "gitHead": "4c8ecf62465ed608f068ef127d2b9f4a23844f6f"
64
64
  }