sql-template-strings
Advanced tools
Comparing version 2.0.2 to 2.0.3
13
index.js
@@ -19,7 +19,2 @@ 'use strict' | ||
/** Returns the SQL Statement for mysql */ | ||
get sql() { | ||
return this.strings.join('?') | ||
} | ||
/** | ||
@@ -50,2 +45,10 @@ * @param {SQLStatement|string} statement | ||
/** Returns the SQL Statement for mysql */ | ||
Object.defineProperty(SQLStatement.prototype, 'sql', { | ||
enumerable: true, | ||
get() { | ||
return this.strings.join('?') | ||
} | ||
}) | ||
/** | ||
@@ -52,0 +55,0 @@ * @param {string[]} strings |
{ | ||
"name": "sql-template-strings", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "ES6 tagged template strings for prepared statements with mysql and postgres", | ||
"main": "index.js", | ||
"typings": "index.d.ts", | ||
"engines": { | ||
@@ -7,0 +8,0 @@ "node": ">4.0.0" |
@@ -7,3 +7,3 @@ [![Version](https://img.shields.io/npm/v/sql-template-strings.svg?maxAge=2592000)](https://www.npmjs.com/package/sql-template-strings) | ||
A simple yet powerful module to allow you to use ES6 tagged template strings for prepared/escaped statements in [mysql](https://www.npmjs.com/package/mysql) / [mysql2](https://www.npmjs.com/package/mysql2) and [postgres](https://www.npmjs.com/package/pq). | ||
A simple yet powerful module to allow you to use ES6 tagged template strings for prepared/escaped statements in [mysql](https://www.npmjs.com/package/mysql) / [mysql2](https://www.npmjs.com/package/mysql2) and [postgres](https://www.npmjs.com/package/pg). | ||
@@ -10,0 +10,0 @@ Example for escaping queries (callbacks omitted): |
@@ -31,2 +31,12 @@ 'use strict' | ||
it('should expose "sql" as an enumerable property', () => { | ||
const query = SQL`SELECT * FROM table` | ||
for (const key in query) { | ||
if (key === 'sql') { | ||
return | ||
} | ||
} | ||
throw new assert.AssertionError({message: 'expected enumerable property "sql"'}) | ||
}) | ||
describe('append()', () => { | ||
@@ -58,3 +68,3 @@ | ||
describe('setName()', () => { | ||
it('should set the name and return this', () => { | ||
@@ -61,0 +71,0 @@ assert.equal(SQL`SELECT * FROM table`.setName('my_query').name, 'my_query') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14246
240