mysql-simple-query
Advanced tools
Comparing version 1.0.23 to 1.0.24
{ | ||
"name": "mysql-simple-query", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "Simple query wrapper for mysql-promise to make querying, inserting, updating, and deleting easier for developers.", | ||
@@ -5,0 +5,0 @@ "main": "mysqlSimpleQuery.js", |
@@ -233,5 +233,5 @@ const dbQuery = require('./util/dbQuery'); | ||
{ | ||
query += `'${value.toString().replace(/'/g, "\\\'")}',` | ||
query += `'${value.toString().replace(/'/g, "\\\'").replace(/"/g, '\\"')}',` | ||
} else { | ||
query += `'${value.toString().replace(/'/g, "\\\'")}'` | ||
query += `'${value.toString().replace(/'/g, "\\\'").replace(/"/g, '\\"')}'` | ||
} | ||
@@ -238,0 +238,0 @@ }); |
@@ -141,3 +141,3 @@ const select = (select) => { | ||
const value = data[key]; | ||
updateData.push(`${key} = "${value.toString().replace(/'/g, "\\'")}"`); | ||
updateData.push(`${key} = "${value.toString().replace(/'/g, "\\'").replace(/"/g, '\\"')}"`); | ||
} | ||
@@ -144,0 +144,0 @@ |
@@ -174,2 +174,14 @@ const expect = require('chai').expect; | ||
it('insert with double quotes in values', () => { | ||
const test = new mysqlSimpleQuery(); | ||
const results = test.insert('product_option_set', { | ||
'product_id': 'this is a"s test', | ||
'option_set_uuid': 2222, | ||
'datetime': '2019-08-27 03:11:06' | ||
}, true); | ||
expect(results).to.equal('INSERT INTO product_option_set (product_id,option_set_uuid,datetime) VALUES (\'this is a\\"s test\',\'2222\',\'2019-08-27 03:11:06\');SELECT LAST_INSERT_ID() AS `id`;'); | ||
}); | ||
it('update without where clause', () => { | ||
@@ -176,0 +188,0 @@ const test = new mysqlSimpleQuery(); |
36847
925