Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sql-strip-comments

decemberster391MIT0.0.23

Remove line and block comments from sql code

sql, strip, comments

readme

npm npm ghit.me

Remove line (-- comment text \n) and block (\* comment text *\) comments from sql code. Comments in string literals are not treated as comments. Nested block comments are not supported.

Install

$ npm install sql-strip-comments --save

Usage

const strip = require("sql-strip-comments");

let sql='SELECT * FROM customers; -- test comments';
console.log(1, strip(sql));
// SELECT * FROM customers; 

sql='SELECT * FROM customers; /* -- test comments */';
console.log(2, strip(sql));
// SELECT * FROM customers; 

sql=`
SELECT 
    "comments can be one line (-- comment text 
) and multiline (/* comment text */)" AS literal, 
    * 
FROM 
    customers; /* -- test comments */`;
console.log(3, strip(sql));
// SELECT "comments can be one line (-- comment text 
// ) and multiline (/* comment text */)" AS literal, * FROM customers;