Skip to content

spatie/sql-comment-parser

Repository files navigation

SQL Comment parser

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

Javascript parser for google/sqlcommenter comments. Learn how to add comments to SQL queries made by Laravel at laravel-sql-commenter.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

npm install sql-comment-parser
yarn add sql-comment-parser

Usage

import { parse } from 'sql-comment-parser';

const { query, comments } = parse("SELECT * FROM FOO /*action='%2Fparam*d',controller='index',framework='spring',traceparent='00-5bd66ef5095369c7b0d1f8f4bd33716a-c532cb4098ac3dd2-01',tracestate='congo%3Dt61rcWkgMzE%2Crojo%3D00f067aa0ba902b7'*/");
//=> query: "SELECT * FROM FOO"
//=> comments: { action: "/param*d", controller: "index", framework: "spring", traceparent: "00-5bd66ef5095369c7b0d1f8f4bd33716a-c532cb4098ac3dd2-01", tracestate: "congo=t61rcWkgMzE,rojo=00f067aa0ba902b7" }

The input may or may not include a valid sql comment. This parser will not check the validity of the input and will do a best effort.

Changelog

Please see releases for more information what has changed recently.

Testing

npm run test

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.