hapiest-mysql
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -151,4 +151,4 @@ 'use strict'; | ||
// Automatically drop Array, Objects, undefined which makes saves times mapping stuff when you have a complicated object structure group multiple tables | ||
if (_.includes(['string', 'number', 'boolean'], typeof(uncleanValue)) || uncleanValue === null) { | ||
// Automatically drop Array, Objects which makes saves times mapping stuff when you have a complicated object structure group multiple tables | ||
if (_.includes(['string', 'number', 'boolean', 'undefined'], typeof(uncleanValue)) || uncleanValue === null) { | ||
const snakeCaseProperty = _.snakeCase(property); | ||
@@ -160,3 +160,4 @@ | ||
} else { | ||
cleanValue = this._clean(uncleanValue); | ||
const valueToClean = typeof(uncleanValue) === 'undefined' ? null : uncleanValue; | ||
cleanValue = this._clean(valueToClean); | ||
} | ||
@@ -178,3 +179,3 @@ | ||
if (uncleanValue === null) { | ||
if (uncleanValue === null || typeof(uncleanValue) === 'undefined') { | ||
sqlObject = sqlObject.where(`${columnName} IS NULL`); | ||
@@ -181,0 +182,0 @@ } else { |
{ | ||
"name": "hapiest-mysql", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "A wrapper around mysql that provides a very descriptive way of running queries.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -243,2 +243,16 @@ 'use strict'; | ||
it('Convert undefined value to null', function() { | ||
const someObj = {firstName: 'John', lastName: 'Doe'}; | ||
const output = mysqlDaoQueryHelper._cleanAndMapValues({ | ||
firstName: someObj.firstName, | ||
lastName: someObj.lastName, | ||
password: someObj.password | ||
}); | ||
Should.exist(output); | ||
output.should.have.properties(['first_name','last_name','password']); | ||
output.first_name.should.eql("'John'"); | ||
output.last_name.should.eql("'Doe'"); | ||
output.password.should.eql("NULL"); | ||
}); | ||
}); | ||
@@ -268,4 +282,15 @@ | ||
it('Should generate good WHERE clause when input contains undefined value (assumes it means NULL)', function() { | ||
const sqlObj = Squel.select().from('users'); | ||
const someObj = {firstName: 'John'}; | ||
mysqlDaoQueryHelper._appendWhereClause(sqlObj, {firstName: someObj.firstName, lastName: someObj.lastName}); | ||
const sqlString = sqlObj.toString(); | ||
sqlString.should.eql("SELECT * FROM users WHERE (first_name = 'John') AND (last_name IS NULL)"); | ||
}); | ||
}); | ||
}); |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
120625
2738
0