Detalhes do pacote

sql-strip-comments

decemberster570MIT0.0.23

Remove line and block comments from sql code

sql, strip, comments

readme (leia-me)

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;