Registry / database / node-sql-parser-etypes

node-sql-parser-etypes

JSON →
library5.3.14jsnpmunverified

A fork of node-sql-parser that adds extra SQL types (e.g., VECTOR) to AST parsing. Version 5.3.14 includes support for multiple database engines (MySQL, PostgreSQL, etc.), an AST-based visitor for table/column lists, and conversion back to SQL. Maintained as a community fork alongside the original taozhi8833998/node-sql-parser. Ships TypeScript types and supports both ESM and CommonJS.

npm install node-sql-parser-etypes
INSTALL
IMPORT
SIG · NODE-SQL-PARSER-ET
N
node-sql-parser-etypes
databasejavascriptv5.3.14
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
import { Parser } from 'node-sql-parser-etypes'
const Parser = require('node-sql-parser-etypes').Parser
Works in both ESM and CJS. In CJS, use destructuring require or access .Parser.
astify
import { Parser } from 'node-sql-parser-etypes'; const parser = new Parser(); const ast = parser.astify('SELECT 1')
import { astify } from 'node-sql-parser-etypes'
astify is a method on Parser instance, not a standalone export.
sqlify
import { Parser } from 'node-sql-parser-etypes'; const parser = new Parser(); const sql = parser.sqlify(ast)
import { sqlify } from 'node-sql-parser-etypes'
sqlify is a method on Parser instance.
NodeSQLParser
const parser = new NodeSQLParser.Parser()
const parser = new NodeSQLParser()
In browser UMD build, the global is NodeSQLParser, which contains the Parser constructor as a property.

Parses a simple SELECT statement into an AST and converts it back to SQL, showing the round-trip behaviour.

import { Parser } from 'node-sql-parser-etypes' const parser = new Parser() const ast = parser.astify('SELECT id, name FROM students WHERE age < 18') console.log(JSON.stringify(ast, null, 2)) const sql = parser.sqlify(ast) console.log(sql) // SELECT `id`, `name` FROM `students` WHERE `age` < 18
Debug
Known issues
gotchaThis is a fork – not the original node-sql-parser. The original maintainer is taozhi8833998. This fork (YaroCabbage) adds extra types like VECTOR but may lag behind on updates.
fix
Check the original package for latest features and stability. Evaluate if extra types justify using the fork.
affects: >=0
breakingIn version 4.x and 5.x, the Parser class API changed from static methods to instance methods. Code using old static methods will break.
fix
Create a Parser instance: const parser = new Parser(); then call parser.astify() / parser.sqlify().
affects: >=4.0.0
deprecatedThe package is no longer actively maintained? Last release was 2022. Issues may not be addressed. Consider the original node-sql-parser or other alternatives.
fix
Migrate to node-sql-parser (original) or ts-sql-parser if you need active maintenance.
affects: >=5.0.0
gotchaAST output may differ from original parser due to extra type support. Use with caution if relying on exact AST structure.
fix
Verify AST shape expected by downstream code with your specific SQL statements.
affects: >=0
Errors
Common errors & fixes
TypeError: parser.astify is not a function
Calling astify as a static method on the class, not on an instance.
fix
const parser = new Parser(); parser.astify('SQL')
Cannot find module 'node-sql-parser' or its corresponding type declarations.
Installed the wrong package? This package is node-sql-parser-etypes, not node-sql-parser.
fix
npm install node-sql-parser-etypes and import from 'node-sql-parser-etypes'.
ReferenceError: NodeSQLParser is not defined
In browser, you included the script but used NodeSQLParser before it loaded, or used wrong script path.
fix
Ensure script src is correct: https://unpkg.com/node-sql-parser-etypes/umd/mysql.umd.js and use after window.onload.
Error: Unsupported column type: VECTOR
This fork should support VECTOR type, but maybe it's not included in the parser instance used (MySQL vs PostgreSQL).
fix
Use parser for the appropriate dialect or check if VECTOR is included in that dialect's grammar.
Upgrade
Version history
5.3.14latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
node-sql-parser-etypes — npm install node-sql-parser-etypes · libregistry