
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
js-sql-parser
Advanced tools
parse / stringify sql (select grammar) in js.
sql grammar follows https://dev.mysql.com/doc/refman/5.7/en/select.html
table_factor
since v1.6.0PlaceHolder like ${param}
since v1.5.0 #43using ' & " for column alias?
since v1.4.1 #40, #44having
since v1.2.1. #29for more changes see CHANGELOG
npm install --save js-sql-parser
const parser = require('js-sql-parser');
const ast = parser.parse('select * from dual');
console.log(JSON.stringify(ast, null, 2));
ast.value.selectItems.value[0].value = 'foo';
ast.value.from.value[0].value.value.value = 'bar';
console.log(parser.stringify(ast));
// SELECT foo FROM bar
// placeholder test
const parser = require('js-sql-parser');
const ast = parser.parse('select ${a} as a');
ast['value']['selectItems']['value'][0]['value'] = "'value'";
console.log(parser.stringify(ast));
// SELECT 'value' AS a
Note: PlaceHolder is an literal
value but not an identifier
. Table_name / column_name / function_name are identifier
thus should NOT be placed with placeholder.
<script src="./dist/parser/sqlParser.js"><script/>
var sqlParser = window.sqlParser;
var ast = sqlParser.parse('select * from dual');
var sql = sqlParser.stringify(ast);
...
npm run build
to build the distributable.MIT
FAQs
> parse / stringify sql (select grammar) in js.
The npm package js-sql-parser receives a total of 37,673 weekly downloads. As such, js-sql-parser popularity was classified as popular.
We found that js-sql-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.