pgsql-deparser 17.12.2 → 17.14.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/kwlist.js ADDED
@@ -0,0 +1,535 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ /**
4
+ * Generated from PostgreSQL kwlist.h
5
+ * DO NOT EDIT BY HAND.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.TYPE_FUNC_NAME_KEYWORDS = exports.COL_NAME_KEYWORDS = exports.UNRESERVED_KEYWORDS = exports.RESERVED_KEYWORDS = exports.kwlist = void 0;
9
+ exports.keywordKindOf = keywordKindOf;
10
+ exports.kwlist = {
11
+ UNRESERVED_KEYWORD: [
12
+ "abort",
13
+ "absent",
14
+ "absolute",
15
+ "access",
16
+ "action",
17
+ "add",
18
+ "admin",
19
+ "after",
20
+ "aggregate",
21
+ "also",
22
+ "alter",
23
+ "always",
24
+ "asensitive",
25
+ "assertion",
26
+ "assignment",
27
+ "at",
28
+ "atomic",
29
+ "attach",
30
+ "attribute",
31
+ "backward",
32
+ "before",
33
+ "begin",
34
+ "breadth",
35
+ "by",
36
+ "cache",
37
+ "call",
38
+ "called",
39
+ "cascade",
40
+ "cascaded",
41
+ "catalog",
42
+ "chain",
43
+ "characteristics",
44
+ "checkpoint",
45
+ "class",
46
+ "close",
47
+ "cluster",
48
+ "columns",
49
+ "comment",
50
+ "comments",
51
+ "commit",
52
+ "committed",
53
+ "compression",
54
+ "conditional",
55
+ "configuration",
56
+ "conflict",
57
+ "connection",
58
+ "constraints",
59
+ "content",
60
+ "continue",
61
+ "conversion",
62
+ "copy",
63
+ "cost",
64
+ "csv",
65
+ "cube",
66
+ "current",
67
+ "cursor",
68
+ "cycle",
69
+ "data",
70
+ "database",
71
+ "day",
72
+ "deallocate",
73
+ "declare",
74
+ "defaults",
75
+ "deferred",
76
+ "definer",
77
+ "delete",
78
+ "delimiter",
79
+ "delimiters",
80
+ "depends",
81
+ "depth",
82
+ "detach",
83
+ "dictionary",
84
+ "disable",
85
+ "discard",
86
+ "document",
87
+ "domain",
88
+ "double",
89
+ "drop",
90
+ "each",
91
+ "empty",
92
+ "enable",
93
+ "encoding",
94
+ "encrypted",
95
+ "enforced",
96
+ "enum",
97
+ "error",
98
+ "escape",
99
+ "event",
100
+ "exclude",
101
+ "excluding",
102
+ "exclusive",
103
+ "execute",
104
+ "explain",
105
+ "expression",
106
+ "extension",
107
+ "external",
108
+ "family",
109
+ "filter",
110
+ "finalize",
111
+ "first",
112
+ "following",
113
+ "force",
114
+ "format",
115
+ "forward",
116
+ "function",
117
+ "functions",
118
+ "generated",
119
+ "global",
120
+ "granted",
121
+ "groups",
122
+ "handler",
123
+ "header",
124
+ "hold",
125
+ "hour",
126
+ "identity",
127
+ "if",
128
+ "ignore",
129
+ "immediate",
130
+ "immutable",
131
+ "implicit",
132
+ "import",
133
+ "include",
134
+ "including",
135
+ "increment",
136
+ "indent",
137
+ "index",
138
+ "indexes",
139
+ "inherit",
140
+ "inherits",
141
+ "inline",
142
+ "input",
143
+ "insensitive",
144
+ "insert",
145
+ "instead",
146
+ "invoker",
147
+ "isolation",
148
+ "keep",
149
+ "key",
150
+ "keys",
151
+ "label",
152
+ "language",
153
+ "large",
154
+ "last",
155
+ "leakproof",
156
+ "level",
157
+ "listen",
158
+ "load",
159
+ "local",
160
+ "location",
161
+ "lock",
162
+ "locked",
163
+ "logged",
164
+ "lsn",
165
+ "mapping",
166
+ "match",
167
+ "matched",
168
+ "materialized",
169
+ "maxvalue",
170
+ "merge",
171
+ "method",
172
+ "minute",
173
+ "minvalue",
174
+ "mode",
175
+ "month",
176
+ "move",
177
+ "name",
178
+ "names",
179
+ "nested",
180
+ "new",
181
+ "next",
182
+ "nfc",
183
+ "nfd",
184
+ "nfkc",
185
+ "nfkd",
186
+ "no",
187
+ "normalized",
188
+ "nothing",
189
+ "notify",
190
+ "nowait",
191
+ "nulls",
192
+ "object",
193
+ "objects",
194
+ "of",
195
+ "off",
196
+ "oids",
197
+ "old",
198
+ "omit",
199
+ "operator",
200
+ "option",
201
+ "options",
202
+ "ordinality",
203
+ "others",
204
+ "over",
205
+ "overriding",
206
+ "owned",
207
+ "owner",
208
+ "parallel",
209
+ "parameter",
210
+ "parser",
211
+ "partial",
212
+ "partition",
213
+ "partitions",
214
+ "passing",
215
+ "password",
216
+ "path",
217
+ "period",
218
+ "plan",
219
+ "plans",
220
+ "policy",
221
+ "preceding",
222
+ "prepare",
223
+ "prepared",
224
+ "preserve",
225
+ "prior",
226
+ "privileges",
227
+ "procedural",
228
+ "procedure",
229
+ "procedures",
230
+ "program",
231
+ "publication",
232
+ "quote",
233
+ "quotes",
234
+ "range",
235
+ "read",
236
+ "reassign",
237
+ "recursive",
238
+ "ref",
239
+ "referencing",
240
+ "refresh",
241
+ "reindex",
242
+ "relative",
243
+ "release",
244
+ "rename",
245
+ "repeatable",
246
+ "replace",
247
+ "replica",
248
+ "reset",
249
+ "respect",
250
+ "restart",
251
+ "restrict",
252
+ "return",
253
+ "returns",
254
+ "revoke",
255
+ "role",
256
+ "rollback",
257
+ "rollup",
258
+ "routine",
259
+ "routines",
260
+ "rows",
261
+ "rule",
262
+ "savepoint",
263
+ "scalar",
264
+ "schema",
265
+ "schemas",
266
+ "scroll",
267
+ "search",
268
+ "second",
269
+ "security",
270
+ "sequence",
271
+ "sequences",
272
+ "serializable",
273
+ "server",
274
+ "session",
275
+ "set",
276
+ "sets",
277
+ "share",
278
+ "show",
279
+ "simple",
280
+ "skip",
281
+ "snapshot",
282
+ "source",
283
+ "split",
284
+ "sql",
285
+ "stable",
286
+ "standalone",
287
+ "start",
288
+ "statement",
289
+ "statistics",
290
+ "stdin",
291
+ "stdout",
292
+ "storage",
293
+ "stored",
294
+ "strict",
295
+ "string",
296
+ "strip",
297
+ "subscription",
298
+ "support",
299
+ "sysid",
300
+ "system",
301
+ "tables",
302
+ "tablespace",
303
+ "target",
304
+ "temp",
305
+ "template",
306
+ "temporary",
307
+ "text",
308
+ "ties",
309
+ "transaction",
310
+ "transform",
311
+ "trigger",
312
+ "truncate",
313
+ "trusted",
314
+ "type",
315
+ "types",
316
+ "uescape",
317
+ "unbounded",
318
+ "uncommitted",
319
+ "unconditional",
320
+ "unencrypted",
321
+ "unknown",
322
+ "unlisten",
323
+ "unlogged",
324
+ "until",
325
+ "update",
326
+ "vacuum",
327
+ "valid",
328
+ "validate",
329
+ "validator",
330
+ "value",
331
+ "varying",
332
+ "version",
333
+ "view",
334
+ "views",
335
+ "virtual",
336
+ "volatile",
337
+ "wait",
338
+ "whitespace",
339
+ "within",
340
+ "without",
341
+ "work",
342
+ "wrapper",
343
+ "write",
344
+ "xml",
345
+ "year",
346
+ "yes",
347
+ "zone"
348
+ ],
349
+ RESERVED_KEYWORD: [
350
+ "all",
351
+ "analyse",
352
+ "analyze",
353
+ "and",
354
+ "any",
355
+ "array",
356
+ "as",
357
+ "asc",
358
+ "asymmetric",
359
+ "both",
360
+ "case",
361
+ "cast",
362
+ "check",
363
+ "collate",
364
+ "column",
365
+ "constraint",
366
+ "create",
367
+ "current_catalog",
368
+ "current_date",
369
+ "current_role",
370
+ "current_time",
371
+ "current_timestamp",
372
+ "current_user",
373
+ "default",
374
+ "deferrable",
375
+ "desc",
376
+ "distinct",
377
+ "do",
378
+ "else",
379
+ "end",
380
+ "except",
381
+ "false",
382
+ "fetch",
383
+ "for",
384
+ "foreign",
385
+ "from",
386
+ "grant",
387
+ "group",
388
+ "having",
389
+ "in",
390
+ "initially",
391
+ "intersect",
392
+ "into",
393
+ "lateral",
394
+ "leading",
395
+ "limit",
396
+ "localtime",
397
+ "localtimestamp",
398
+ "not",
399
+ "null",
400
+ "offset",
401
+ "on",
402
+ "only",
403
+ "or",
404
+ "order",
405
+ "placing",
406
+ "primary",
407
+ "references",
408
+ "returning",
409
+ "select",
410
+ "session_user",
411
+ "some",
412
+ "symmetric",
413
+ "system_user",
414
+ "table",
415
+ "then",
416
+ "to",
417
+ "trailing",
418
+ "true",
419
+ "union",
420
+ "unique",
421
+ "user",
422
+ "using",
423
+ "variadic",
424
+ "when",
425
+ "where",
426
+ "window",
427
+ "with"
428
+ ],
429
+ TYPE_FUNC_NAME_KEYWORD: [
430
+ "authorization",
431
+ "binary",
432
+ "collation",
433
+ "concurrently",
434
+ "cross",
435
+ "current_schema",
436
+ "freeze",
437
+ "full",
438
+ "ilike",
439
+ "inner",
440
+ "is",
441
+ "isnull",
442
+ "join",
443
+ "left",
444
+ "like",
445
+ "natural",
446
+ "notnull",
447
+ "outer",
448
+ "overlaps",
449
+ "right",
450
+ "similar",
451
+ "tablesample",
452
+ "verbose"
453
+ ],
454
+ COL_NAME_KEYWORD: [
455
+ "between",
456
+ "bigint",
457
+ "bit",
458
+ "boolean",
459
+ "char",
460
+ "character",
461
+ "coalesce",
462
+ "dec",
463
+ "decimal",
464
+ "exists",
465
+ "extract",
466
+ "float",
467
+ "greatest",
468
+ "grouping",
469
+ "inout",
470
+ "int",
471
+ "integer",
472
+ "interval",
473
+ "json",
474
+ "json_array",
475
+ "json_arrayagg",
476
+ "json_exists",
477
+ "json_object",
478
+ "json_objectagg",
479
+ "json_query",
480
+ "json_scalar",
481
+ "json_serialize",
482
+ "json_table",
483
+ "json_value",
484
+ "least",
485
+ "merge_action",
486
+ "national",
487
+ "nchar",
488
+ "none",
489
+ "normalize",
490
+ "nullif",
491
+ "numeric",
492
+ "out",
493
+ "overlay",
494
+ "position",
495
+ "precision",
496
+ "real",
497
+ "row",
498
+ "setof",
499
+ "smallint",
500
+ "substring",
501
+ "time",
502
+ "timestamp",
503
+ "treat",
504
+ "trim",
505
+ "values",
506
+ "varchar",
507
+ "xmlattributes",
508
+ "xmlconcat",
509
+ "xmlelement",
510
+ "xmlexists",
511
+ "xmlforest",
512
+ "xmlnamespaces",
513
+ "xmlparse",
514
+ "xmlpi",
515
+ "xmlroot",
516
+ "xmlserialize",
517
+ "xmltable"
518
+ ]
519
+ };
520
+ exports.RESERVED_KEYWORDS = new Set(exports.kwlist.RESERVED_KEYWORD ?? []);
521
+ exports.UNRESERVED_KEYWORDS = new Set(exports.kwlist.UNRESERVED_KEYWORD ?? []);
522
+ exports.COL_NAME_KEYWORDS = new Set(exports.kwlist.COL_NAME_KEYWORD ?? []);
523
+ exports.TYPE_FUNC_NAME_KEYWORDS = new Set(exports.kwlist.TYPE_FUNC_NAME_KEYWORD ?? []);
524
+ function keywordKindOf(word) {
525
+ const w = word.toLowerCase();
526
+ if (exports.RESERVED_KEYWORDS.has(w))
527
+ return "RESERVED_KEYWORD";
528
+ if (exports.TYPE_FUNC_NAME_KEYWORDS.has(w))
529
+ return "TYPE_FUNC_NAME_KEYWORD";
530
+ if (exports.COL_NAME_KEYWORDS.has(w))
531
+ return "COL_NAME_KEYWORD";
532
+ if (exports.UNRESERVED_KEYWORDS.has(w))
533
+ return "UNRESERVED_KEYWORD";
534
+ return "NO_KEYWORD";
535
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "17.12.2",
3
+ "version": "17.14.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL AST Deparser",
6
6
  "main": "index.js",
@@ -40,7 +40,8 @@
40
40
  "organize-transformers": "ts-node scripts/organize-transformers-by-version.ts",
41
41
  "generate-version-deparsers": "ts-node scripts/generate-version-deparsers.ts",
42
42
  "generate-packages": "ts-node scripts/generate-version-packages.ts",
43
- "prepare-versions": "npm run strip-transformer-types && npm run strip-direct-transformer-types && npm run strip-deparser-types && npm run organize-transformers && npm run generate-version-deparsers && npm run generate-packages"
43
+ "prepare-versions": "npm run strip-transformer-types && npm run strip-direct-transformer-types && npm run strip-deparser-types && npm run organize-transformers && npm run generate-version-deparsers && npm run generate-packages",
44
+ "keywords": "ts-node scripts/keywords.ts"
44
45
  },
45
46
  "keywords": [
46
47
  "sql",
@@ -59,5 +60,5 @@
59
60
  "dependencies": {
60
61
  "@pgsql/types": "^17.6.2"
61
62
  },
62
- "gitHead": "de2ac125ad90c1299238b4c2f24d355bde36adb7"
63
+ "gitHead": "48ea4210dc676c26c3ca4de8650cdd64c4eb3bd3"
63
64
  }
@@ -1,6 +1,4 @@
1
1
  export declare class QuoteUtils {
2
- static needsQuotes(value: string): boolean;
3
- static quote(value: any): any;
4
2
  static escape(literal: string): string;
5
3
  /**
6
4
  * Escapes a string value for use in E-prefixed string literals
@@ -17,4 +15,51 @@ export declare class QuoteUtils {
17
15
  * Detects backslash escape sequences that require E-prefix in PostgreSQL
18
16
  */
19
17
  static needsEscapePrefix(value: string): boolean;
18
+ /**
19
+ * Quote an identifier only if needed
20
+ *
21
+ * This is a TypeScript port of PostgreSQL's quote_identifier() function from ruleutils.c
22
+ * https://github.com/postgres/postgres/blob/fab5cd3dd1323f9e66efeb676c4bb212ff340204/src/backend/utils/adt/ruleutils.c#L13055-L13137
23
+ *
24
+ * Can avoid quoting if ident starts with a lowercase letter or underscore
25
+ * and contains only lowercase letters, digits, and underscores, *and* is
26
+ * not any SQL keyword. Otherwise, supply quotes.
27
+ *
28
+ * When quotes are needed, embedded double quotes are properly escaped as "".
29
+ */
30
+ static quoteIdentifier(ident: string): string;
31
+ /**
32
+ * Quote an identifier that appears after a dot in a qualified name.
33
+ *
34
+ * In PostgreSQL's grammar, identifiers that appear after a dot (e.g., schema.name,
35
+ * table.column) are in a more permissive position that accepts all keyword categories
36
+ * including RESERVED_KEYWORD. This means we only need to quote for lexical reasons
37
+ * (uppercase, special characters, leading digits) not for keyword reasons.
38
+ *
39
+ * Empirically verified: `myschema.select`, `myschema.float`, `t.from` all parse
40
+ * successfully in PostgreSQL without quotes.
41
+ */
42
+ static quoteIdentifierAfterDot(ident: string): string;
43
+ /**
44
+ * Quote a dotted name (e.g., schema.table, catalog.schema.table).
45
+ *
46
+ * The first part uses strict quoting (keywords are quoted), while subsequent
47
+ * parts use relaxed quoting (keywords allowed, only quote for lexical reasons).
48
+ *
49
+ * This reflects PostgreSQL's grammar where the first identifier in a statement
50
+ * may conflict with keywords, but identifiers after a dot are in a more
51
+ * permissive position.
52
+ */
53
+ static quoteDottedName(parts: string[]): string;
54
+ /**
55
+ * Quote a possibly-qualified identifier
56
+ *
57
+ * This is inspired by PostgreSQL's quote_qualified_identifier() function from ruleutils.c
58
+ * but uses relaxed quoting for the tail component since PostgreSQL's grammar accepts
59
+ * all keywords in qualified name positions.
60
+ *
61
+ * Return a name of the form qualifier.ident, or just ident if qualifier
62
+ * is null/undefined, quoting each component if necessary.
63
+ */
64
+ static quoteQualifiedIdentifier(qualifier: string | null | undefined, ident: string): string;
20
65
  }