|
|
|
@ -47,11 +47,11 @@ function prepareLikeValue(value) {
|
|
|
|
|
function prepareIsValue(value) { |
|
|
|
|
|
|
|
|
|
//return value.replace("~", "%");
|
|
|
|
|
if(value === 'null'){ |
|
|
|
|
if (value === 'null') { |
|
|
|
|
return null; |
|
|
|
|
} else if (value === 'true'){ |
|
|
|
|
} else if (value === 'true') { |
|
|
|
|
return true; |
|
|
|
|
} else if (value === 'false'){ |
|
|
|
|
} else if (value === 'false') { |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
return null |
|
|
|
@ -59,6 +59,23 @@ function prepareIsValue(value) {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function prepareBetweenValue(value) { |
|
|
|
|
|
|
|
|
|
let values = value.split(',') |
|
|
|
|
let obj = {} |
|
|
|
|
obj.whereQuery = '' |
|
|
|
|
obj.whereParams = [] |
|
|
|
|
|
|
|
|
|
if (values.length === 2) { |
|
|
|
|
obj.whereQuery = ' ? and ? ' |
|
|
|
|
obj.whereParams.push(values[0]) |
|
|
|
|
obj.whereParams.push(values[1]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//console.log('prepareBetweenValue', obj);
|
|
|
|
|
|
|
|
|
|
return obj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function replaceWhereParamsToQMarks(openParentheses, str, comparisonOperator) { |
|
|
|
@ -76,7 +93,7 @@ function replaceWhereParamsToQMarks(openParentheses, str, comparisonOperator) {
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
if (comparisonOperator !== ' in ') |
|
|
|
|
if (comparisonOperator !== ' in ' && comparisonOperator !== ' between ') |
|
|
|
|
converted = '?' |
|
|
|
|
|
|
|
|
|
for (var i = str.length - 1; i >= 0; --i) { |
|
|
|
@ -147,6 +164,10 @@ function getComparisonOperator(operator) {
|
|
|
|
|
return ' in ' |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'bw': |
|
|
|
|
return ' between ' |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
return null |
|
|
|
|
break; |
|
|
|
@ -271,6 +292,11 @@ exports.getConditionClause = function (whereInQueryParams, condType = 'where') {
|
|
|
|
|
whereParams.push(prepareLikeValue(variableValue[1])) |
|
|
|
|
} else if (comparisonOperator === ' is ') { |
|
|
|
|
whereParams.push(prepareIsValue(variableValue[1])) |
|
|
|
|
} else if (comparisonOperator === ' between ') { |
|
|
|
|
let obj = prepareBetweenValue(variableValue[1]) |
|
|
|
|
whereQuery += obj.whereQuery |
|
|
|
|
whereParams = whereParams.concat(obj.whereParams) |
|
|
|
|
//console.log(whereQuery, whereParams);
|
|
|
|
|
} else { |
|
|
|
|
whereParams.push(variableValue[1]) |
|
|
|
|
} |
|
|
|
|