Skip to content

Commit d7df025

Browse files
committed
MySQLConnector.js,SnowflakeConnector.js,JSONConnector.js,InfluxConnector.js,BigQueryConnector.js,ClickhouseConnector.js - Updated Filter condition to use '=' instead of IN for single value
RedShiftConnector.js,CassandraConnector.js - Updated Filter condition to use '=' instead of IN for single value & Escape single quote in Data MSSQLConnector.js - Escape single Quote in Data
1 parent 452cd94 commit d7df025

9 files changed

+47
-7
lines changed

BigQueryConnector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,11 @@ function createSingleCondition(obj) {
796796
}
797797

798798
if (operator != undefined) {
799+
if(Array.isArray(value) && value.length ==1)
800+
{
801+
const updatedValue = value[0];
802+
value = updatedValue;
803+
}
799804
var sign = operatorSign(operator, value);
800805
if (sign.indexOf("IN") > -1) {
801806
//IN condition has different format

CassandraConnector.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,15 @@ function createSingleCondition(obj) {
580580
}
581581

582582
if (operator != undefined) {
583+
if(Array.isArray(value) && value.length ==1)
584+
{
585+
const updatedValue = value[0];
586+
value = updatedValue;
587+
}
583588
var sign = operatorSign(operator, value);
584589
if (sign.indexOf('IN') > -1) { //IN condition has different format
585590
if (typeof value[0] == 'string') {
586-
conditiontext += ' ' + sign + ' (\'' + value.join('\',\'') + '\')';
591+
conditiontext += ' ' + sign + ' (\'' + value.map((e) => e.replace(/'/g, "''")).join("','") + '\')';
587592
} else {
588593
conditiontext += ' ' + sign + ' (' + value.join(',') + ')';
589594
}
@@ -598,7 +603,7 @@ function createSingleCondition(obj) {
598603
}
599604
} else {
600605
if (typeof value == 'string') {
601-
tempValue = '\'' + value + '\'';
606+
tempValue = '\'' + value.replace(/'/g, "''") + '\'';
602607
} else {
603608
tempValue = value;
604609
}

ClickhouseConnector.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,15 @@ function createSingleCondition(obj) {
526526
}
527527

528528
if (operator != undefined) {
529+
if(Array.isArray(value) && value.length ==1)
530+
{
531+
const updatedValue = value[0];
532+
value = updatedValue;
533+
}
529534
var sign = operatorSign(operator, value);
530535
if (sign.indexOf('IN') > -1) { //IN condition has different format
531536
if (typeof value[0] == 'string') {
532-
conditiontext += ' ' + sign + " ('" + value.join("','") + "')";
537+
conditiontext += ' ' + sign + " ('" + value.map((d) => (d != null ? d.toString().replace(/\'/gi, "\\'") : d)).join("','") + "')";
533538
} else {
534539
conditiontext += ' ' + sign + ' (' + value.join(',') + ')';
535540
}
@@ -544,7 +549,7 @@ function createSingleCondition(obj) {
544549
}
545550
} else {
546551
if (typeof value == 'string') {
547-
tempValue = '\'' + value + '\'';
552+
tempValue = '\'' + replaceSingleQuote(value) + '\'';
548553
} else {
549554
tempValue = value;
550555
}

InfluxConnector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ function createSingleCondition(obj) {
365365
}
366366

367367
if (operator != undefined) {
368+
if(Array.isArray(value) && value.length ==1)
369+
{
370+
const updatedValue = value[0];
371+
value = updatedValue;
372+
}
368373
var sign = operatorSign(operator, value);
369374
if (sign.indexOf('IN') > -1) {
370375
//IN condition has different format for Influx

JSONConnector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ function createSingleCondition(obj) {
256256
}
257257

258258
if (operator != undefined) {
259+
if(Array.isArray(value) && value.length ==1)
260+
{
261+
const updatedValue = value[0];
262+
value = updatedValue;
263+
}
259264
var sign = operatorSign(operator, value);
260265
if (sign.indexOf('IN') > -1) { //IN condition has different format
261266
var tempValue = value.map(d => d != null ? d.toString().replace(/\'/ig, "\\\'") : d).join("','");

MSSQLConnector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ function createSingleCondition(obj) {
635635
var sign = operatorSign(operator, value);
636636
if (sign.indexOf('IN') > -1) { //IN condition has different format
637637
if (typeof value[0] == 'string') {
638-
conditiontext += " " + sign + " ('" + value.join("','") + "')";
638+
conditiontext += " " + sign + " ('" + value.map((e) => e.replace(/'/g, "''")).join("','") + "')";
639639
} else {
640640
conditiontext += " " + sign + " ('" + value.join(",") + ")";
641641
}

MySQLConnector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ function createSingleCondition(obj) {
634634
}
635635

636636
if (operator != undefined) {
637+
if(Array.isArray(value) && value.length ==1)
638+
{
639+
const updatedValue = value[0];
640+
value = updatedValue;
641+
}
637642
var sign = operatorSign(operator, value);
638643
if (sign.indexOf('IN') > -1) { //IN condition has different format
639644
var tempValue = value.map(d => d != null ? d.toString().replace(/\'/ig, "\\\'") : d).join("','");

RedShiftConnector.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,14 @@ function createSingleCondition(obj) {
654654
}
655655

656656
if (operator != undefined) {
657+
if(Array.isArray(value) && value.length ==1)
658+
{
659+
const updatedValue = value[0];
660+
value = updatedValue;
661+
}
657662
var sign = operatorSign(operator, value);
658663
if (sign.indexOf('IN') > -1) { //IN condition has different format
659-
conditiontext += ' ' + sign + ' (\'' + value.join("','") + '\')';
664+
conditiontext += ' ' + sign + ' (\'' + value.map((e) => e.replace(/'/g, "''")).join("','") + '\')';
660665
} else {
661666
var tempValue = '';
662667
if (typeof value === 'undefined' || value == null) {
@@ -668,7 +673,7 @@ function createSingleCondition(obj) {
668673
tempValue = encloseField(rTable) + '.' + encloseField(value.field);
669674
}
670675
} else {
671-
tempValue = '\'' + value + '\'';
676+
tempValue = '\'' + value.replace(/'/g, "''") + '\'';
672677
}
673678
conditiontext += ' ' + sign + ' ' + tempValue;
674679
}

SnowflakeConnector.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,11 @@ function createSingleCondition(obj) {
635635
}
636636

637637
if (operator != undefined) {
638+
if(Array.isArray(value) && value.length ==1)
639+
{
640+
const updatedValue = value[0];
641+
value = updatedValue;
642+
}
638643
var sign = operatorSign(operator, value);
639644
if (sign.indexOf('IN') > -1) { //IN condition has different format
640645
if (typeof value[0] == 'string') {

0 commit comments

Comments
 (0)