pgsql-deparser 17.9.0 → 17.10.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/README.md CHANGED
@@ -99,7 +99,7 @@ The deparser accepts optional configuration for formatting and output control:
99
99
  import { deparseSync as deparse } from 'pgsql-deparser';
100
100
 
101
101
  const options = {
102
- pretty: true, // Enable pretty formatting (default: false)
102
+ pretty: true, // Enable pretty formatting (default: true)
103
103
  newline: '\n', // Newline character (default: '\n')
104
104
  tab: ' ', // Tab/indentation character (default: ' ')
105
105
  semicolons: true // Add semicolons to statements (default: true)
@@ -110,7 +110,7 @@ const sql = deparse(ast, options);
110
110
 
111
111
  | Option | Type | Default | Description |
112
112
  |--------|------|---------|-------------|
113
- | `pretty` | `boolean` | `false` | Enable pretty formatting with indentation and line breaks |
113
+ | `pretty` | `boolean` | `true` | Enable pretty formatting with indentation and line breaks |
114
114
  | `newline` | `string` | `'\n'` | Character(s) used for line breaks |
115
115
  | `tab` | `string` | `' '` | Character(s) used for indentation |
116
116
  | `semicolons` | `boolean` | `true` | Add semicolons to SQL statements |
package/deparser.js CHANGED
@@ -1711,6 +1711,24 @@ class Deparser {
1711
1711
  typeName = 'time with time zone';
1712
1712
  }
1713
1713
  }
1714
+ else if (type === 'timestamp') {
1715
+ if (args) {
1716
+ typeName = `timestamp(${args})`;
1717
+ args = null; // Don't apply args again in mods()
1718
+ }
1719
+ else {
1720
+ typeName = 'timestamp';
1721
+ }
1722
+ }
1723
+ else if (type === 'time') {
1724
+ if (args) {
1725
+ typeName = `time(${args})`;
1726
+ args = null; // Don't apply args again in mods()
1727
+ }
1728
+ else {
1729
+ typeName = 'time';
1730
+ }
1731
+ }
1714
1732
  let result = mods(typeName, args);
1715
1733
  if (node.arrayBounds && node.arrayBounds.length > 0) {
1716
1734
  result += formatArrayBounds(node.arrayBounds);
package/esm/deparser.js CHANGED
@@ -1708,6 +1708,24 @@ export class Deparser {
1708
1708
  typeName = 'time with time zone';
1709
1709
  }
1710
1710
  }
1711
+ else if (type === 'timestamp') {
1712
+ if (args) {
1713
+ typeName = `timestamp(${args})`;
1714
+ args = null; // Don't apply args again in mods()
1715
+ }
1716
+ else {
1717
+ typeName = 'timestamp';
1718
+ }
1719
+ }
1720
+ else if (type === 'time') {
1721
+ if (args) {
1722
+ typeName = `time(${args})`;
1723
+ args = null; // Don't apply args again in mods()
1724
+ }
1725
+ else {
1726
+ typeName = 'time';
1727
+ }
1728
+ }
1711
1729
  let result = mods(typeName, args);
1712
1730
  if (node.arrayBounds && node.arrayBounds.length > 0) {
1713
1731
  result += formatArrayBounds(node.arrayBounds);
@@ -2,7 +2,7 @@ export class SqlFormatter {
2
2
  newlineChar;
3
3
  tabChar;
4
4
  prettyMode;
5
- constructor(newlineChar = '\n', tabChar = ' ', prettyMode = false) {
5
+ constructor(newlineChar = '\n', tabChar = ' ', prettyMode = true) {
6
6
  this.newlineChar = newlineChar;
7
7
  this.tabChar = tabChar;
8
8
  this.prettyMode = prettyMode;
@@ -19,7 +19,7 @@ export class DeparserContext {
19
19
  isEnumValue;
20
20
  objtype;
21
21
  subtype;
22
- constructor({ indentLevel = 0, prettyMode = false, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest } = {}) {
22
+ constructor({ indentLevel = 0, prettyMode = true, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest } = {}) {
23
23
  this.indentLevel = indentLevel;
24
24
  this.prettyMode = prettyMode;
25
25
  this.isStringLiteral = isStringLiteral;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "17.9.0",
3
+ "version": "17.10.0",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "PostgreSQL AST Deparser",
6
6
  "main": "index.js",
@@ -58,5 +58,5 @@
58
58
  "dependencies": {
59
59
  "@pgsql/types": "^17.6.1"
60
60
  },
61
- "gitHead": "c2982c6793a8e92395a32e5d9d656b04e060466b"
61
+ "gitHead": "ccaa3c5ef9104de83e8c2624706520e4a2be5e88"
62
62
  }
@@ -5,7 +5,7 @@ class SqlFormatter {
5
5
  newlineChar;
6
6
  tabChar;
7
7
  prettyMode;
8
- constructor(newlineChar = '\n', tabChar = ' ', prettyMode = false) {
8
+ constructor(newlineChar = '\n', tabChar = ' ', prettyMode = true) {
9
9
  this.newlineChar = newlineChar;
10
10
  this.tabChar = tabChar;
11
11
  this.prettyMode = prettyMode;
package/visitors/base.js CHANGED
@@ -22,7 +22,7 @@ class DeparserContext {
22
22
  isEnumValue;
23
23
  objtype;
24
24
  subtype;
25
- constructor({ indentLevel = 0, prettyMode = false, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest } = {}) {
25
+ constructor({ indentLevel = 0, prettyMode = true, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest } = {}) {
26
26
  this.indentLevel = indentLevel;
27
27
  this.prettyMode = prettyMode;
28
28
  this.isStringLiteral = isStringLiteral;