|
14 | 14 | <a href="https://www.npmjs.com/package/pgsql-deparser"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/pgsql-parser?filename=packages%2Fdeparser%2Fpackage.json"/></a>
|
15 | 15 | </p>
|
16 | 16 |
|
17 |
| -`pgsql-deparser` is a streamlined tool designed to convert PostgreSQL Abstract Syntax Trees (AST) back into SQL queries. It is a companion module to [`pgsql-parser`](https://github.com/launchql/pgsql-parser), which is capable of both parsing SQL queries into ASTs and deparsing these ASTs back into SQL. However, unlike `pgsql-parser`, which incorporates the full PostgreSQL parser, `pgsql-deparser` focuses solely on the deparser functionality. This makes it an excellent choice for scenarios where only AST-to-SQL conversion is needed, avoiding the extra overhead associated with the full parsing capabilities. |
| 17 | +`pgsql-deparser` is the lightning-fast, pure TypeScript solution for converting PostgreSQL ASTs back into SQL queries. Perfect companion to [`pgsql-parser`](https://github.com/launchql/pgsql-parser), this focused tool delivers SQL generation without any native dependencies or WebAssembly overhead. |
18 | 18 |
|
19 | 19 | ## Installation
|
20 | 20 |
|
21 | 21 | ```sh
|
22 | 22 | npm install pgsql-deparser
|
23 | 23 | ```
|
24 | 24 |
|
25 |
| -## Key Features |
| 25 | +## Features |
26 | 26 |
|
27 |
| -- **Lightweight and Pure TypeScript**: Built entirely in TypeScript, `pgsql-deparser` is lightweight and doesn't rely on native dependencies, facilitating easier integration and deployment across various environments. |
28 |
| -- **Focused Functionality**: By concentrating on decompiling ASTs to SQL, `pgsql-deparser` offers a specialized, efficient solution for those who need to generate SQL statements from ASTs without the full parsing mechanism. |
29 |
| -- **Compatibility**: Ideal for use cases where the AST is already obtained from another source or process, allowing for seamless SQL generation from AST representations. |
| 27 | +* ⚡ **Pure TypeScript Performance** – Zero dependencies, no WASM, no compilation - just blazing fast SQL generation |
| 28 | +* 🪶 **Ultra Lightweight** – Minimal footprint with laser-focused functionality for AST-to-SQL conversion only |
| 29 | +* 🧪 **Battle-Tested Reliability** – Validated against 23,000+ SQL statements ensuring production-grade stability |
| 30 | +* 🌍 **Universal Compatibility** – Runs anywhere JavaScript does - browsers, Node.js, edge functions, you name it |
30 | 31 |
|
31 | 32 | ## Deparser Example
|
32 | 33 |
|
@@ -76,43 +77,41 @@ console.log(deparse(stmt));
|
76 | 77 |
|
77 | 78 | As of PG 13, PG majors versions maintained will have a matching dedicated major npm version. Only the latest Postgres stable release receives active updates.
|
78 | 79 |
|
79 |
| -Our latest is built with `13-latest` branch from libpg_query |
| 80 | +Our latest is built with `17-latest` branch from libpg_query |
80 | 81 |
|
81 |
| -| PostgreSQL Major Version | libpg_query | Status | npm |
| 82 | +| PostgreSQL Major Version | libpg_query | Status | npm tag | |
82 | 83 | |--------------------------|-------------|---------------------|---------|
|
83 |
| -| 13 | 13-latest | Active development | `latest` |
| 84 | +| 17 | 17-latest | Active Development | `latest` | |
| 85 | +| 16 | (n/a) | Not supported | |
| 86 | +| 15 | (n/a) | Not supported | |
| 87 | +| 14 | (n/a) | Not supported | |
| 88 | +| 13 | 13-latest | Only Critical Fixes | `13.16.0` | |
84 | 89 | | 12 | (n/a) | Not supported |
|
85 | 90 | | 11 | (n/a) | Not supported |
|
86 | 91 | | 10 | 10-latest | Not supported | `@1.3.1` ([tree](https://github.com/launchql/pgsql-parser/tree/39b7b1adc8914253226e286a48105785219a81ca)) |
|
87 | 92 |
|
| 93 | +## Credits |
88 | 94 |
|
89 |
| -## Related |
90 |
| - |
91 |
| -* [pgsql-parser](https://github.com/launchql/pgsql-parser): The real PostgreSQL parser for Node.js, providing symmetric parsing and deparsing of SQL statements with actual PostgreSQL parser integration. |
92 |
| -* [pgsql-deparser](https://github.com/launchql/pgsql-parser/tree/main/packages/deparser): A streamlined tool designed for converting PostgreSQL ASTs back into SQL queries, focusing solely on deparser functionality to complement `pgsql-parser`. |
93 |
| -* [pgsql-enums](https://github.com/launchql/pgsql-parser/tree/main/packages/pgsql-enums): A utility package offering easy access to PostgreSQL enumeration types in JSON format, aiding in string and integer conversions of enums used within ASTs to compliment `pgsql-parser` |
94 |
| -* [@pgsql/enums](https://github.com/launchql/pgsql-parser/tree/main/packages/enums): Provides PostgreSQL AST enums in TypeScript, enhancing type safety and usability in projects interacting with PostgreSQL AST nodes. |
95 |
| -* [@pgsql/types](https://github.com/launchql/pgsql-parser/tree/main/packages/types): Offers TypeScript type definitions for PostgreSQL AST nodes, facilitating type-safe construction, analysis, and manipulation of ASTs. |
96 |
| -* [@pgsql/utils](https://github.com/launchql/pgsql-parser/tree/main/packages/utils): A comprehensive utility library for PostgreSQL, offering type-safe AST node creation and enum value conversions, simplifying the construction and manipulation of PostgreSQL ASTs. |
97 |
| -* [pg-proto-parser](https://github.com/launchql/pg-proto-parser): A TypeScript tool that parses PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums. |
98 |
| -* [libpg-query](https://github.com/launchql/libpg-query-node): The real PostgreSQL parser exposed for Node.js, used primarily in `pgsql-parser` for parsing and deparsing SQL queries. |
99 |
| - |
100 |
| -Thanks [@lfittl](https://github.com/lfittl) for building the core `libpg_query` suite: |
101 |
| - |
102 |
| -* [libpg_query](https://github.com/pganalyze/libpg_query) |
103 |
| -* [pg_query](https://github.com/lfittl/pg_query) |
104 |
| -* [pg_query.go](https://github.com/lfittl/pg_query.go) |
| 95 | +Built on the excellent work of several contributors: |
105 | 96 |
|
106 |
| -## Credits |
| 97 | +* **[Dan Lynch](https://github.com/pyramation)** — official maintainer since 2018 and architect of the current implementation |
| 98 | +* **[Lukas Fittl](https://github.com/lfittl)** for [libpg_query](https://github.com/pganalyze/libpg_query) — the core PostgreSQL parser that powers this project |
| 99 | +* **[Greg Richardson](https://github.com/gregnr)** for AST guidance and pushing the transition to WASM for better interoperability |
| 100 | +* **[Ethan Resnick](https://github.com/ethanresnick)** for the original Node.js N-API bindings |
| 101 | +* **[Zac McCormick](https://github.com/zhm)** for the foundational [node-pg-query-native](https://github.com/zhm/node-pg-query-native) parser |
107 | 102 |
|
108 |
| -Thanks to [@zhm](https://github.com/zhm) for the OG parser that started it all: |
| 103 | +## Related |
109 | 104 |
|
110 |
| -* [pg-query-parser](https://github.com/zhm/pg-query-parser) |
111 |
| -* [pg-query-native](https://github.com/zhm/node-pg-query-native) |
112 |
| -* [Original LICENSE](https://github.com/zhm/pg-query-parser/blob/master/LICENSE.md) |
| 105 | +* [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): The real PostgreSQL parser for Node.js, providing symmetric parsing and deparsing of SQL statements with actual PostgreSQL parser integration. |
| 106 | +* [pgsql-deparser](https://www.npmjs.com/package/pgsql-deparser): A streamlined tool designed for converting PostgreSQL ASTs back into SQL queries, focusing solely on deparser functionality to complement `pgsql-parser`. |
| 107 | +* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): Offers TypeScript type definitions for PostgreSQL AST nodes, facilitating type-safe construction, analysis, and manipulation of ASTs. |
| 108 | +* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): Provides TypeScript enum definitions for PostgreSQL constants, enabling type-safe usage of PostgreSQL enums and constants in your applications. |
| 109 | +* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): A comprehensive utility library for PostgreSQL, offering type-safe AST node creation and enum value conversions, simplifying the construction and manipulation of PostgreSQL ASTs. |
| 110 | +* [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): A TypeScript tool that parses PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums. |
| 111 | +* [libpg-query](https://github.com/launchql/libpg-query-node): The real PostgreSQL parser exposed for Node.js, used primarily in `pgsql-parser` for parsing and deparsing SQL queries. |
113 | 112 |
|
114 | 113 | ## Disclaimer
|
115 | 114 |
|
116 |
| -AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. |
| 115 | +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. |
117 | 116 |
|
118 | 117 | No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
0 commit comments