diff --git a/README.md b/README.md index fafe6f4..4b019ef 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ +# sqlstring-sqlite + +A SQLite version of `mysqljs/sqlstring`. + +I just changed the variables `CHARS_GLOBAL_REGEXP` and `CHARS_ESCAPE_MAP` in file `mysqljs/sqlstring/lib/SqlString.js` +to let the project fitting to SQLite. + +## Install + +```sh +$ npm install sqlstring-sqlite +``` + +NOTE: Unit test is not changed, so the tests won't pass. + +Following is the origin README.md of `mysqljs/sqlstring` +--- + # sqlstring [![NPM Version][npm-version-image]][npm-url] diff --git a/lib/SqlString.js b/lib/SqlString.js index 419adec..1b02052 100644 --- a/lib/SqlString.js +++ b/lib/SqlString.js @@ -2,19 +2,12 @@ var SqlString = exports; var ID_GLOBAL_REGEXP = /`/g; var QUAL_GLOBAL_REGEXP = /\./g; -var CHARS_GLOBAL_REGEXP = /[\0\b\t\n\r\x1a\"\'\\]/g; // eslint-disable-line no-control-regex +var CHARS_GLOBAL_REGEXP = /[']/g; var CHARS_ESCAPE_MAP = { - '\0' : '\\0', - '\b' : '\\b', - '\t' : '\\t', - '\n' : '\\n', - '\r' : '\\r', - '\x1a' : '\\Z', - '"' : '\\"', - '\'' : '\\\'', - '\\' : '\\\\' + '\'': '\'\'', }; + SqlString.escapeId = function escapeId(val, forbidQualified) { if (Array.isArray(val)) { var sql = ''; diff --git a/package.json b/package.json index 2c951a3..859b27d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "sqlstring", - "description": "Simple SQL escape and format for MySQL", - "version": "2.3.1", + "name": "sqlstring-sqlite", + "description": "Simple SQL escape and format for SQLite", + "version": "0.1.1", "contributors": [ "Adri Van Houdt ", "Douglas Christopher Wilson ", @@ -15,9 +15,10 @@ "sqlstring", "sql", "escape", - "sql escape" + "sql escape", + "sqlite" ], - "repository": "mysqljs/sqlstring", + "repository": "pastgift/sqlstring-sqlite-js", "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "2.1.4",