pgsql-deparser 16.0.0 → 17.1.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 +45 -88
- package/deparser.d.ts +253 -0
- package/{deparser/deparser.js → deparser.js} +180 -579
- package/esm/{deparser/deparser.js → deparser.js} +180 -579
- package/esm/index.js +3 -15
- package/esm/utils/index.js +90 -0
- package/esm/{deparser/utils → utils}/list-utils.js +0 -4
- package/esm/{deparser/utils → utils}/quote-utils.js +0 -34
- package/esm/utils/sql-formatter.js +23 -0
- package/esm/{deparser/visitors → visitors}/base.js +0 -4
- package/index.d.ts +3 -9
- package/index.js +4 -16
- package/package.json +27 -14
- package/utils/index.d.ts +4 -0
- package/utils/index.js +97 -0
- package/{deparser/utils → utils}/list-utils.d.ts +0 -4
- package/{deparser/utils → utils}/list-utils.js +0 -4
- package/utils/quote-utils.d.ts +5 -0
- package/{deparser/utils → utils}/quote-utils.js +0 -34
- package/{deparser/utils → utils}/sql-formatter.d.ts +1 -7
- package/{deparser/utils → utils}/sql-formatter.js +2 -15
- package/{deparser/visitors → visitors}/base.d.ts +5 -8
- package/{deparser/visitors → visitors}/base.js +0 -4
- package/deparser/deparser.d.ts +0 -301
- package/deparser/index.d.ts +0 -9
- package/deparser/index.js +0 -17
- package/deparser/utils/quote-utils.d.ts +0 -24
- package/esm/deparser/index.js +0 -13
- package/esm/deparser/utils/sql-formatter.js +0 -36
- package/esm/v16-to-v17-direct.js +0 -44
- package/esm/v16-to-v17.js +0 -1488
- package/v16-to-v17-direct.d.ts +0 -21
- package/v16-to-v17-direct.js +0 -48
- package/v16-to-v17.d.ts +0 -638
- package/v16-to-v17.js +0 -1492
package/esm/index.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
import { deparse as deparse17, deparseSync as deparseSync17 } from './deparser';
|
|
6
|
-
import { PG16ToPG17Transformer } from './v16-to-v17-direct';
|
|
7
|
-
const tx = new PG16ToPG17Transformer();
|
|
8
|
-
export async function deparse(query, opts) {
|
|
9
|
-
const ast17 = tx.transform(query);
|
|
10
|
-
return await deparse17(ast17, opts);
|
|
11
|
-
}
|
|
12
|
-
export function deparseSync(query, opts) {
|
|
13
|
-
const ast17 = tx.transform(query);
|
|
14
|
-
return deparseSync17(ast17, opts);
|
|
15
|
-
}
|
|
1
|
+
import { Deparser } from "./deparser";
|
|
2
|
+
const deparse = Deparser.deparse;
|
|
3
|
+
export { deparse, Deparser };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
|
+
export const cleanLines = (sql) => {
|
|
3
|
+
return sql
|
|
4
|
+
.split('\n')
|
|
5
|
+
.map((l) => l.trim())
|
|
6
|
+
.filter((a) => a)
|
|
7
|
+
.join('\n');
|
|
8
|
+
};
|
|
9
|
+
export const transform = (obj, props) => {
|
|
10
|
+
let copy = null;
|
|
11
|
+
// Handle the 3 simple types, and null or undefined
|
|
12
|
+
if (obj == null || typeof obj !== 'object') {
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
// Handle Date
|
|
16
|
+
if (obj instanceof Date) {
|
|
17
|
+
copy = new Date();
|
|
18
|
+
copy.setTime(obj.getTime());
|
|
19
|
+
return copy;
|
|
20
|
+
}
|
|
21
|
+
// Handle Array
|
|
22
|
+
if (obj instanceof Array) {
|
|
23
|
+
copy = [];
|
|
24
|
+
for (let i = 0, len = obj.length; i < len; i++) {
|
|
25
|
+
copy[i] = transform(obj[i], props);
|
|
26
|
+
}
|
|
27
|
+
return copy;
|
|
28
|
+
}
|
|
29
|
+
// Handle Object
|
|
30
|
+
if (obj instanceof Object || typeof obj === 'object') {
|
|
31
|
+
copy = {};
|
|
32
|
+
for (const attr in obj) {
|
|
33
|
+
if (obj.hasOwnProperty(attr)) {
|
|
34
|
+
if (props.hasOwnProperty(attr)) {
|
|
35
|
+
if (typeof props[attr] === 'function') {
|
|
36
|
+
copy[attr] = props[attr](obj[attr]);
|
|
37
|
+
}
|
|
38
|
+
else if (props[attr].hasOwnProperty(obj[attr])) {
|
|
39
|
+
copy[attr] = props[attr][obj[attr]];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
copy[attr] = transform(obj[attr], props);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
copy[attr] = transform(obj[attr], props);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
copy[attr] = transform(obj[attr], props);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return copy;
|
|
54
|
+
}
|
|
55
|
+
throw new Error("Unable to copy obj! Its type isn't supported.");
|
|
56
|
+
};
|
|
57
|
+
const noop = () => undefined;
|
|
58
|
+
export const cleanTree = (tree) => {
|
|
59
|
+
return transform(tree, {
|
|
60
|
+
stmt_len: noop,
|
|
61
|
+
stmt_location: noop,
|
|
62
|
+
location: noop,
|
|
63
|
+
DefElem: (obj) => {
|
|
64
|
+
if (obj.defname === 'as') {
|
|
65
|
+
if (Array.isArray(obj.arg) && obj.arg.length) {
|
|
66
|
+
// function
|
|
67
|
+
obj.arg[0].String.sval = obj.arg[0].String.sval.trim();
|
|
68
|
+
}
|
|
69
|
+
else if (obj.arg.List && obj.arg.List.items) {
|
|
70
|
+
// function
|
|
71
|
+
obj.arg.List.items[0].String.sval = obj.arg.List.items[0].String.sval.trim();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// do stmt
|
|
75
|
+
obj.arg.String.sval = obj.arg.String.sval.trim();
|
|
76
|
+
}
|
|
77
|
+
return cleanTree(obj);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return cleanTree(obj);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export const cleanTreeWithStmt = (tree) => {
|
|
86
|
+
return transform(tree, {
|
|
87
|
+
stmt_location: noop,
|
|
88
|
+
location: noop
|
|
89
|
+
});
|
|
90
|
+
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
-
*/
|
|
5
1
|
const RESERVED_WORDS = new Set([
|
|
6
2
|
'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc', 'asymmetric',
|
|
7
3
|
'authorization', 'binary', 'both', 'case', 'cast', 'check', 'collate', 'collation',
|
|
@@ -52,34 +48,4 @@ export class QuoteUtils {
|
|
|
52
48
|
static escape(literal) {
|
|
53
49
|
return `'${literal.replace(/'/g, "''")}'`;
|
|
54
50
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Escapes a string value for use in E-prefixed string literals
|
|
57
|
-
* Handles both backslashes and single quotes properly
|
|
58
|
-
*/
|
|
59
|
-
static escapeEString(value) {
|
|
60
|
-
return value.replace(/\\/g, '\\\\').replace(/'/g, "''");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Formats a string as an E-prefixed string literal with proper escaping
|
|
64
|
-
* This wraps the complete E-prefix logic including detection and formatting
|
|
65
|
-
*/
|
|
66
|
-
static formatEString(value) {
|
|
67
|
-
const needsEscape = QuoteUtils.needsEscapePrefix(value);
|
|
68
|
-
if (needsEscape) {
|
|
69
|
-
const escapedValue = QuoteUtils.escapeEString(value);
|
|
70
|
-
return `E'${escapedValue}'`;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
return QuoteUtils.escape(value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Determines if a string value needs E-prefix for escaped string literals
|
|
78
|
-
* Detects backslash escape sequences that require E-prefix in PostgreSQL
|
|
79
|
-
*/
|
|
80
|
-
static needsEscapePrefix(value) {
|
|
81
|
-
// Always use E'' if the string contains any backslashes,
|
|
82
|
-
// unless it's a raw \x... bytea-style literal.
|
|
83
|
-
return !/^\\x[0-9a-fA-F]+$/i.test(value) && value.includes('\\');
|
|
84
|
-
}
|
|
85
51
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class SqlFormatter {
|
|
2
|
+
newlineChar;
|
|
3
|
+
tabChar;
|
|
4
|
+
constructor(newlineChar = '\n', tabChar = ' ') {
|
|
5
|
+
this.newlineChar = newlineChar;
|
|
6
|
+
this.tabChar = tabChar;
|
|
7
|
+
}
|
|
8
|
+
format(parts, separator = ' ') {
|
|
9
|
+
return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
|
|
10
|
+
}
|
|
11
|
+
indent(text, count = 1) {
|
|
12
|
+
return text;
|
|
13
|
+
}
|
|
14
|
+
parens(content) {
|
|
15
|
+
return `(${content})`;
|
|
16
|
+
}
|
|
17
|
+
newline() {
|
|
18
|
+
return this.newlineChar;
|
|
19
|
+
}
|
|
20
|
+
tab() {
|
|
21
|
+
return this.tabChar;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
import { Node, ParseResult } from '@pgsql/types';
|
|
6
|
-
import { DeparserOptions } from './deparser';
|
|
7
|
-
export declare function deparse(query: Node | Node[] | ParseResult, opts?: DeparserOptions): Promise<string>;
|
|
8
|
-
export declare function deparseSync(query: Node | Node[] | ParseResult, opts?: DeparserOptions): string;
|
|
9
|
-
export { DeparserOptions } from './deparser';
|
|
1
|
+
import { Deparser } from "./deparser";
|
|
2
|
+
declare const deparse: typeof Deparser.deparse;
|
|
3
|
+
export { deparse, Deparser };
|
package/index.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Deparser for PostgreSQL version 16
|
|
4
|
-
* Auto-generated by generate-version-deparsers.ts
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.deparse =
|
|
8
|
-
exports.deparseSync = deparseSync;
|
|
3
|
+
exports.Deparser = exports.deparse = void 0;
|
|
9
4
|
const deparser_1 = require("./deparser");
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const ast17 = tx.transform(query);
|
|
14
|
-
return await (0, deparser_1.deparse)(ast17, opts);
|
|
15
|
-
}
|
|
16
|
-
function deparseSync(query, opts) {
|
|
17
|
-
const ast17 = tx.transform(query);
|
|
18
|
-
return (0, deparser_1.deparseSync)(ast17, opts);
|
|
19
|
-
}
|
|
5
|
+
Object.defineProperty(exports, "Deparser", { enumerable: true, get: function () { return deparser_1.Deparser; } });
|
|
6
|
+
const deparse = deparser_1.Deparser.deparse;
|
|
7
|
+
exports.deparse = deparse;
|
package/package.json
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
+
"name": "pgsql-deparser",
|
|
3
|
+
"version": "17.1.0",
|
|
2
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
3
|
-
"
|
|
4
|
-
"license": "MIT",
|
|
5
|
+
"description": "PostgreSQL AST Deparser",
|
|
5
6
|
"main": "index.js",
|
|
6
7
|
"module": "esm/index.js",
|
|
7
8
|
"types": "index.d.ts",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"copy": "copyfiles -f ../../../../LICENSE README.md package.json dist",
|
|
11
|
-
"clean": "rimraf dist",
|
|
12
|
-
"build": "npm run clean && tsc && tsc -p tsconfig.esm.json && npm run copy",
|
|
13
|
-
"publish:pkg": "npm publish --tag pg16"
|
|
14
|
-
},
|
|
9
|
+
"homepage": "https://github.com/launchql/pgsql-parser",
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
15
11
|
"publishConfig": {
|
|
16
12
|
"access": "public",
|
|
17
13
|
"directory": "dist"
|
|
@@ -23,6 +19,21 @@
|
|
|
23
19
|
"bugs": {
|
|
24
20
|
"url": "https://github.com/launchql/pgsql-parser/issues"
|
|
25
21
|
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"copy": "copyfiles -f ../../LICENSE README.md package.json dist",
|
|
24
|
+
"clean": "rimraf dist",
|
|
25
|
+
"prepare": "npm run build",
|
|
26
|
+
"build": "npm run clean && tsc && tsc -p tsconfig.esm.json && npm run copy",
|
|
27
|
+
"build:dev": "npm run clean && tsc --declarationMap && tsc -p tsconfig.esm.json && npm run copy",
|
|
28
|
+
"kitchen-sink": "npm run fixtures && npm run fixtures:kitchen-sink",
|
|
29
|
+
"fixtures:kitchen-sink": "ts-node scripts/make-kitchen-sink.ts",
|
|
30
|
+
"fixtures:ast": "ts-node scripts/make-fixtures-ast.ts",
|
|
31
|
+
"fixtures:sql": "ts-node scripts/make-fixtures-sql.ts",
|
|
32
|
+
"fixtures": "ts-node scripts/make-fixtures.ts",
|
|
33
|
+
"lint": "eslint . --fix",
|
|
34
|
+
"test": "jest",
|
|
35
|
+
"test:watch": "jest --watch"
|
|
36
|
+
},
|
|
26
37
|
"keywords": [
|
|
27
38
|
"sql",
|
|
28
39
|
"postgres",
|
|
@@ -33,9 +44,11 @@
|
|
|
33
44
|
"deparser",
|
|
34
45
|
"database"
|
|
35
46
|
],
|
|
36
|
-
"
|
|
37
|
-
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"libpg-query": "17.3.3"
|
|
49
|
+
},
|
|
38
50
|
"dependencies": {
|
|
39
|
-
"@pgsql/types": "^
|
|
40
|
-
}
|
|
41
|
-
|
|
51
|
+
"@pgsql/types": "^17.1.0"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "40ee618df37a501169847056a50558c453cd30a6"
|
|
54
|
+
}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-restricted-syntax */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.cleanTreeWithStmt = exports.cleanTree = exports.transform = exports.cleanLines = void 0;
|
|
5
|
+
const cleanLines = (sql) => {
|
|
6
|
+
return sql
|
|
7
|
+
.split('\n')
|
|
8
|
+
.map((l) => l.trim())
|
|
9
|
+
.filter((a) => a)
|
|
10
|
+
.join('\n');
|
|
11
|
+
};
|
|
12
|
+
exports.cleanLines = cleanLines;
|
|
13
|
+
const transform = (obj, props) => {
|
|
14
|
+
let copy = null;
|
|
15
|
+
// Handle the 3 simple types, and null or undefined
|
|
16
|
+
if (obj == null || typeof obj !== 'object') {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
// Handle Date
|
|
20
|
+
if (obj instanceof Date) {
|
|
21
|
+
copy = new Date();
|
|
22
|
+
copy.setTime(obj.getTime());
|
|
23
|
+
return copy;
|
|
24
|
+
}
|
|
25
|
+
// Handle Array
|
|
26
|
+
if (obj instanceof Array) {
|
|
27
|
+
copy = [];
|
|
28
|
+
for (let i = 0, len = obj.length; i < len; i++) {
|
|
29
|
+
copy[i] = (0, exports.transform)(obj[i], props);
|
|
30
|
+
}
|
|
31
|
+
return copy;
|
|
32
|
+
}
|
|
33
|
+
// Handle Object
|
|
34
|
+
if (obj instanceof Object || typeof obj === 'object') {
|
|
35
|
+
copy = {};
|
|
36
|
+
for (const attr in obj) {
|
|
37
|
+
if (obj.hasOwnProperty(attr)) {
|
|
38
|
+
if (props.hasOwnProperty(attr)) {
|
|
39
|
+
if (typeof props[attr] === 'function') {
|
|
40
|
+
copy[attr] = props[attr](obj[attr]);
|
|
41
|
+
}
|
|
42
|
+
else if (props[attr].hasOwnProperty(obj[attr])) {
|
|
43
|
+
copy[attr] = props[attr][obj[attr]];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
copy[attr] = (0, exports.transform)(obj[attr], props);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
copy[attr] = (0, exports.transform)(obj[attr], props);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
copy[attr] = (0, exports.transform)(obj[attr], props);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return copy;
|
|
58
|
+
}
|
|
59
|
+
throw new Error("Unable to copy obj! Its type isn't supported.");
|
|
60
|
+
};
|
|
61
|
+
exports.transform = transform;
|
|
62
|
+
const noop = () => undefined;
|
|
63
|
+
const cleanTree = (tree) => {
|
|
64
|
+
return (0, exports.transform)(tree, {
|
|
65
|
+
stmt_len: noop,
|
|
66
|
+
stmt_location: noop,
|
|
67
|
+
location: noop,
|
|
68
|
+
DefElem: (obj) => {
|
|
69
|
+
if (obj.defname === 'as') {
|
|
70
|
+
if (Array.isArray(obj.arg) && obj.arg.length) {
|
|
71
|
+
// function
|
|
72
|
+
obj.arg[0].String.sval = obj.arg[0].String.sval.trim();
|
|
73
|
+
}
|
|
74
|
+
else if (obj.arg.List && obj.arg.List.items) {
|
|
75
|
+
// function
|
|
76
|
+
obj.arg.List.items[0].String.sval = obj.arg.List.items[0].String.sval.trim();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// do stmt
|
|
80
|
+
obj.arg.String.sval = obj.arg.String.sval.trim();
|
|
81
|
+
}
|
|
82
|
+
return (0, exports.cleanTree)(obj);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return (0, exports.cleanTree)(obj);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
exports.cleanTree = cleanTree;
|
|
91
|
+
const cleanTreeWithStmt = (tree) => {
|
|
92
|
+
return (0, exports.transform)(tree, {
|
|
93
|
+
stmt_location: noop,
|
|
94
|
+
location: noop
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
exports.cleanTreeWithStmt = cleanTreeWithStmt;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
-
*/
|
|
5
1
|
export declare class ListUtils {
|
|
6
2
|
static unwrapList(obj: any): any[];
|
|
7
3
|
static formatList(items: any[], separator: string, prefix: string, formatter: (item: any) => string): string;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
4
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.QuoteUtils = void 0;
|
|
8
4
|
const RESERVED_WORDS = new Set([
|
|
@@ -55,35 +51,5 @@ class QuoteUtils {
|
|
|
55
51
|
static escape(literal) {
|
|
56
52
|
return `'${literal.replace(/'/g, "''")}'`;
|
|
57
53
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Escapes a string value for use in E-prefixed string literals
|
|
60
|
-
* Handles both backslashes and single quotes properly
|
|
61
|
-
*/
|
|
62
|
-
static escapeEString(value) {
|
|
63
|
-
return value.replace(/\\/g, '\\\\').replace(/'/g, "''");
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Formats a string as an E-prefixed string literal with proper escaping
|
|
67
|
-
* This wraps the complete E-prefix logic including detection and formatting
|
|
68
|
-
*/
|
|
69
|
-
static formatEString(value) {
|
|
70
|
-
const needsEscape = QuoteUtils.needsEscapePrefix(value);
|
|
71
|
-
if (needsEscape) {
|
|
72
|
-
const escapedValue = QuoteUtils.escapeEString(value);
|
|
73
|
-
return `E'${escapedValue}'`;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return QuoteUtils.escape(value);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Determines if a string value needs E-prefix for escaped string literals
|
|
81
|
-
* Detects backslash escape sequences that require E-prefix in PostgreSQL
|
|
82
|
-
*/
|
|
83
|
-
static needsEscapePrefix(value) {
|
|
84
|
-
// Always use E'' if the string contains any backslashes,
|
|
85
|
-
// unless it's a raw \x... bytea-style literal.
|
|
86
|
-
return !/^\\x[0-9a-fA-F]+$/i.test(value) && value.includes('\\');
|
|
87
|
-
}
|
|
88
54
|
}
|
|
89
55
|
exports.QuoteUtils = QuoteUtils;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
-
*/
|
|
5
1
|
export declare class SqlFormatter {
|
|
6
2
|
private newlineChar;
|
|
7
3
|
private tabChar;
|
|
8
|
-
|
|
9
|
-
constructor(newlineChar?: string, tabChar?: string, prettyMode?: boolean);
|
|
4
|
+
constructor(newlineChar?: string, tabChar?: string);
|
|
10
5
|
format(parts: string[], separator?: string): string;
|
|
11
6
|
indent(text: string, count?: number): string;
|
|
12
7
|
parens(content: string): string;
|
|
13
8
|
newline(): string;
|
|
14
9
|
tab(): string;
|
|
15
|
-
isPretty(): boolean;
|
|
16
10
|
}
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
4
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.SqlFormatter = void 0;
|
|
8
4
|
class SqlFormatter {
|
|
9
5
|
newlineChar;
|
|
10
6
|
tabChar;
|
|
11
|
-
|
|
12
|
-
constructor(newlineChar = '\n', tabChar = ' ', prettyMode = false) {
|
|
7
|
+
constructor(newlineChar = '\n', tabChar = ' ') {
|
|
13
8
|
this.newlineChar = newlineChar;
|
|
14
9
|
this.tabChar = tabChar;
|
|
15
|
-
this.prettyMode = prettyMode;
|
|
16
10
|
}
|
|
17
11
|
format(parts, separator = ' ') {
|
|
18
12
|
return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
|
|
19
13
|
}
|
|
20
14
|
indent(text, count = 1) {
|
|
21
|
-
|
|
22
|
-
return text;
|
|
23
|
-
}
|
|
24
|
-
const indentation = this.tabChar.repeat(count);
|
|
25
|
-
return text.split(this.newlineChar).map(line => line.trim() ? indentation + line : line).join(this.newlineChar);
|
|
15
|
+
return text;
|
|
26
16
|
}
|
|
27
17
|
parens(content) {
|
|
28
18
|
return `(${content})`;
|
|
@@ -33,8 +23,5 @@ class SqlFormatter {
|
|
|
33
23
|
tab() {
|
|
34
24
|
return this.tabChar;
|
|
35
25
|
}
|
|
36
|
-
isPretty() {
|
|
37
|
-
return this.prettyMode;
|
|
38
|
-
}
|
|
39
26
|
}
|
|
40
27
|
exports.SqlFormatter = SqlFormatter;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
-
*/
|
|
1
|
+
import { Node } from '@pgsql/types';
|
|
5
2
|
export interface DeparserContext {
|
|
6
3
|
isStringLiteral?: boolean;
|
|
7
4
|
parentNodeTypes: string[];
|
|
8
5
|
[key: string]: any;
|
|
9
6
|
}
|
|
10
7
|
export interface DeparserVisitor {
|
|
11
|
-
visit(node:
|
|
8
|
+
visit(node: Node, context?: DeparserContext): string;
|
|
12
9
|
}
|
|
13
10
|
export declare abstract class BaseVisitor implements DeparserVisitor {
|
|
14
|
-
abstract visit(node:
|
|
15
|
-
protected getNodeType(node:
|
|
16
|
-
protected getNodeData(node:
|
|
11
|
+
abstract visit(node: Node, context?: DeparserContext): string;
|
|
12
|
+
protected getNodeType(node: Node): string;
|
|
13
|
+
protected getNodeData(node: Node): any;
|
|
17
14
|
protected formatList(items: any[], separator: string, prefix: string, formatter: (item: any) => string): string;
|
|
18
15
|
protected formatParts(parts: string[], separator?: string): string;
|
|
19
16
|
protected formatParens(content: string): string;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Auto-generated file with types stripped for better tree-shaking
|
|
4
|
-
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.BaseVisitor = void 0;
|
|
8
4
|
class BaseVisitor {
|