pgsql-deparser
Advanced tools
Comparing version 0.8.7 to 1.0.0
@@ -6,4 +6,4 @@ # Change Log | ||
## 0.8.7 (2020-10-19) | ||
# 1.0.0 (2020-10-19) | ||
**Note:** Version bump only for package pgsql-deparser |
{ | ||
"name": "pgsql-deparser", | ||
"version": "0.8.7", | ||
"version": "1.0.0", | ||
"description": "PostgreSQL AST Deparser", | ||
@@ -68,3 +68,3 @@ "author": "Dan Lynch <pyramation@gmail.com>", | ||
"jest": "^25.1.0", | ||
"pgsql-parser": "0.8.6", | ||
"pgsql-parser": "^1.0.0", | ||
"prettier": "^2.1.2", | ||
@@ -77,5 +77,5 @@ "regenerator-runtime": "^0.13.2" | ||
"lodash": "4.17.20", | ||
"pgsql-enums": "0.8.6" | ||
"pgsql-enums": "^1.0.0" | ||
}, | ||
"gitHead": "7bd4bfa2657f084abaddc60613bc748b9c171850" | ||
"gitHead": "41cc18892bb28f20df32ad9b50c668a88cdf9813" | ||
} |
@@ -1,1 +0,81 @@ | ||
# pgsql-deparser | ||
# pgsql-parser [](https://travis-ci.org/pyramation/pgsql-parser) | ||
The real PostgreSQL parser for nodejs. The primary objective of this module is to provide symmetric parsing | ||
and deparsing of SQL statements. With this module you can modify parts of a SQL query statement and | ||
serialize the query tree back into a formatted SQL statement. It uses the *real* [PostgreSQL parser](https://github.com/lfittl/libpg_query). | ||
The main functionality provided by this module is deparsing, which PostgreSQL does not have internally. | ||
## Installation | ||
```sh | ||
npm install pgsql-parser | ||
``` | ||
## Example | ||
Rewrite part of a SQL query: | ||
```js | ||
const parser = require('pgsql-parser'); | ||
const query = parser.parse('SELECT * FROM test_table'); | ||
query[0].SelectStmt.fromClause[0].RangeVar.relname = 'another_table'; | ||
console.log(parser.deparse(query)); | ||
// SELECT * FROM "another_table" | ||
``` | ||
### Documentation | ||
### `parser.parse(sql)` | ||
Parses the query and returns a parse object. | ||
### Parameters | ||
| parameter | type | description | | ||
| -------------------- | ------------------ | --------------------------------------------------------- | | ||
| `query` | String | SQL query | | ||
Returns an object in the format: | ||
``` | ||
{ query: <query|Object>, | ||
error: { message: <message|String>, | ||
fileName: <fileName|String>, | ||
lineNumber: <line|Number>, | ||
cursorPosition: <cursor|Number> } | ||
``` | ||
### `parser.deparse(query)` | ||
Deparses the query tree and returns a formatted SQL statement. This function takes as input a query AST | ||
in the same format as the `query` property of on the result of the `parse` method. This is the primary | ||
functionality of this module. | ||
### Parameters | ||
| parameter | type | description | | ||
| -------------------- | ------------------ | --------------------------------------------------------- | | ||
| `query` | Object | Query tree obtained from `parse` | | ||
Returns a normalized formatted SQL string. | ||
## Related | ||
* [pg-query-native-latest](https://github.com/pyramation/node-pg-query-native) | ||
* [libpg_query](https://github.com/lfittl/libpg_query) | ||
* [pg_query](https://github.com/lfittl/pg_query) | ||
* [pg_query.go](https://github.com/lfittl/pg_query.go) | ||
## Credits | ||
* [pg-query-parser](https://github.com/zhm/pg-query-parser) | ||
* [pg-query-native](https://github.com/zhm/node-pg-query-native) | ||
License: https://github.com/zhm/pg-query-parser/blob/master/LICENSE.md | ||
Thanks to https://github.com/zhm/pg-query-parser we've been able to start this repo and add a lot of functionality |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
183004
1
82
+ Addedpgsql-enums@1.1.1(transitive)
- Removedpgsql-enums@0.8.6(transitive)
Updatedpgsql-enums@^1.0.0