New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pgsql-deparser

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pgsql-deparser - npm Package Compare versions

Comparing version 0.8.7 to 1.0.0

2

CHANGELOG.md

@@ -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 [![Build Status](https://travis-ci.org/pyramation/pgsql-parser.svg?branch=master)](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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc