mysql-simple-query
Advanced tools
Comparing version 1.0.24 to 1.0.25
@@ -228,5 +228,5 @@ const dbQuery = require('./util/dbQuery'); | ||
if (key !== last) { | ||
query += `'${value.toString().replace(/'/g, "\\\'")}',`; | ||
query += `'${value}',`; | ||
} else { | ||
query += `'${value.toString().replace(/'/g, "\\\'")}'`; | ||
query += `'${value}'`; | ||
} | ||
@@ -269,2 +269,2 @@ }); | ||
module.exports = mysqlSimpleQuery; | ||
module.exports = mysqlSimpleQuery; |
@@ -132,3 +132,3 @@ const select = select => { | ||
const value = data[key]; | ||
updateData.push(`${key} = "${value.toString().replace(/'/g, "\\'")}"`); | ||
updateData.push(`${key} = "${value}"`); | ||
} | ||
@@ -152,2 +152,2 @@ | ||
offset | ||
}; | ||
}; |
{ | ||
"name": "mysql-simple-query", | ||
"version": "1.0.24", | ||
"version": "1.0.25", | ||
"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, "\\\'").replace(/"/g, '\\"')}',` | ||
query += `'${value}',` | ||
} else { | ||
query += `'${value.toString().replace(/'/g, "\\\'").replace(/"/g, '\\"')}'` | ||
query += `'${value}'` | ||
} | ||
@@ -238,0 +238,0 @@ }); |
@@ -141,3 +141,3 @@ const select = (select) => { | ||
const value = data[key]; | ||
updateData.push(`${key} = "${value.toString().replace(/'/g, "\\'").replace(/"/g, '\\"')}"`); | ||
updateData.push(`${key} = "${value}"`); | ||
} | ||
@@ -144,0 +144,0 @@ |
@@ -162,26 +162,2 @@ const expect = require('chai').expect; | ||
it('insert with single 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('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', () => { | ||
@@ -188,0 +164,0 @@ const test = new mysqlSimpleQuery(); |
35554
909