Feature : 'is' operator in where clause npm v0.3.0

This commit is contained in:
oof1lab
2017-11-14 18:43:36 +05:30
parent a33ae8595d
commit a165dcb779
5 changed files with 60 additions and 9 deletions

View File

@@ -44,6 +44,22 @@ function prepareLikeValue(value) {
}
function prepareIsValue(value) {
//return value.replace("~", "%");
if(value === 'null'){
return null;
} else if (value === 'true'){
return true;
} else if (value === 'false'){
return false;
} else {
return null
}
}
function replaceWhereParamsToQMarks(openParentheses, str, comparisonOperator) {
@@ -103,13 +119,13 @@ function getComparisonOperator(operator) {
return '>='
break;
// case 'is':
// return ' is '
// break;
case 'is':
return ' is '
break;
// case 'isnot':
// return ' is not '
// break;
case 'isnot':
return ' is not '
break;
// case 'isnull':
// return ' is NULL '
@@ -253,6 +269,8 @@ exports.getConditionClause = function (whereInQueryParams, condType = 'where') {
whereParams = whereParams.concat(obj.whereParams)
} else if (comparisonOperator === ' like ' || comparisonOperator === ' not like ') {
whereParams.push(prepareLikeValue(variableValue[1]))
} else if (comparisonOperator === ' is ') {
whereParams.push(prepareIsValue(variableValue[1]))
} else {
whereParams.push(variableValue[1])
}