|
|
@ -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) { |
|
|
|
function replaceWhereParamsToQMarks(openParentheses, str, comparisonOperator) { |
|
|
@ -76,7 +93,7 @@ function replaceWhereParamsToQMarks(openParentheses, str, comparisonOperator) { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
if (comparisonOperator !== ' in ') |
|
|
|
if (comparisonOperator !== ' in ' && comparisonOperator !== ' between ') |
|
|
|
converted = '?' |
|
|
|
converted = '?' |
|
|
|
|
|
|
|
|
|
|
|
for (var i = str.length - 1; i >= 0; --i) { |
|
|
|
for (var i = str.length - 1; i >= 0; --i) { |
|
|
@ -147,6 +164,10 @@ function getComparisonOperator(operator) { |
|
|
|
return ' in ' |
|
|
|
return ' in ' |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'bw': |
|
|
|
|
|
|
|
return ' between ' |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return null |
|
|
|
return null |
|
|
|
break; |
|
|
|
break; |
|
|
@ -271,6 +292,11 @@ exports.getConditionClause = function (whereInQueryParams, condType = 'where') { |
|
|
|
whereParams.push(prepareLikeValue(variableValue[1])) |
|
|
|
whereParams.push(prepareLikeValue(variableValue[1])) |
|
|
|
} else if (comparisonOperator === ' is ') { |
|
|
|
} else if (comparisonOperator === ' is ') { |
|
|
|
whereParams.push(prepareIsValue(variableValue[1])) |
|
|
|
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 { |
|
|
|
} else { |
|
|
|
whereParams.push(variableValue[1]) |
|
|
|
whereParams.push(variableValue[1]) |
|
|
|
} |
|
|
|
} |
|
|
|