From 5a48a4656e8542f3690bd51c13d56789fa20dfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=91=EC=A4=80=ED=98=81?= Date: Tue, 7 May 2024 13:59:21 +0900 Subject: [PATCH 1/6] fix: Issue/604 --- .../dsl/functions/restriction/ColumnRestriction.java | 7 ++++++- .../dsl/functions/restriction/RestrictionsTest.java | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java b/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java index 05f27970f6d..2f46b7ffe69 100644 --- a/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java +++ b/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java @@ -192,7 +192,12 @@ public String toString() { String value; if (fieldValue instanceof String) { - value = "\"" + escapeDoubleQuotes((String) fieldValue) + "\""; + if(operator.contains("~")){ + value = escapeDoubleQuotes((String) fieldValue); + } + else{ + value = "\"" + escapeDoubleQuotes((String) fieldValue) + "\""; + } } else { value = FunctionsParameters.serializeValue(fieldValue, false); } diff --git a/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java b/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java index 7a700535602..747447e4307 100644 --- a/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java +++ b/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java @@ -74,6 +74,17 @@ void contains() { Assertions.assertThat(restrictions.toString()).isEqualTo("contains(value: r[\"_value\"], set:[\"value1\", \"value2\"])"); } + @Test + void custom(){ + Restrictions restrictions = Restrictions.value().custom("/.*target.*/", "=~"); + + Assertions.assertThat(restrictions.toString()).isEqualTo("r[\"_value\"] =~ /.*target.*/"); + + restrictions = Restrictions.value().custom("1", "=="); + + Assertions.assertThat(restrictions.toString()).isEqualTo("r[\"_value\"] == \"1\""); + } + @Test void not() { @@ -109,6 +120,7 @@ void escaping() { restrictions = Restrictions.tag("_value").contains(new String[]{"val\"ue1", "value2"}); + Assertions.assertThat(restrictions.toString()).isEqualTo("contains(value: r[\"_value\"], set:[\"val\\\"ue1\", \"value2\"])"); Flux flux = Flux From a2ae22db3f14adf8c38d87d10c29f510063e3005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=91=EC=A4=80=ED=98=81?= Date: Tue, 7 May 2024 14:22:02 +0900 Subject: [PATCH 2/6] docs: update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e087ce9bfce..6bb3a319df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ 1. [#684](https://github.com/influxdata/influxdb-client-java/issues/684): Fix checking for CSV end of table marker when parsing CSV stream to InfluxQLQueryResult, needed for example when parsing the results of a query like "SHOW SERIES". 2. [#662](https://github.com/influxdata/influxdb-client-java/issues/662): Adds to FluxDsl support for the `|> elapsed(unit)` function. 3. [#623](https://github.com/influxdata/influxdb-client-java/issues/623): Enables the use of IPv6 addresses. +4. [#604](https://github.com/influxdata/influxdb-client-java/issues/604): custom function operator comparison bug fix ### Dependencies From c367d833d2df5d40905fdd1f2f327832495c146f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=91=EC=A4=80=ED=98=81?= Date: Tue, 7 May 2024 14:33:06 +0900 Subject: [PATCH 3/6] chore: revert line --- .../query/dsl/functions/restriction/RestrictionsTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java b/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java index 747447e4307..ab7628e7609 100644 --- a/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java +++ b/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java @@ -120,7 +120,6 @@ void escaping() { restrictions = Restrictions.tag("_value").contains(new String[]{"val\"ue1", "value2"}); - Assertions.assertThat(restrictions.toString()).isEqualTo("contains(value: r[\"_value\"], set:[\"val\\\"ue1\", \"value2\"])"); Flux flux = Flux From 61db15819a9dd524fee4e3fb64f49f5a5d980c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bedn=C3=A1=C5=99?= Date: Tue, 7 May 2024 10:18:08 +0200 Subject: [PATCH 4/6] fix: code style --- .../query/dsl/functions/restriction/ColumnRestriction.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java b/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java index 2f46b7ffe69..2daf791e221 100644 --- a/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java +++ b/flux-dsl/src/main/java/com/influxdb/query/dsl/functions/restriction/ColumnRestriction.java @@ -192,10 +192,9 @@ public String toString() { String value; if (fieldValue instanceof String) { - if(operator.contains("~")){ + if (operator.contains("~")) { value = escapeDoubleQuotes((String) fieldValue); - } - else{ + } else { value = "\"" + escapeDoubleQuotes((String) fieldValue) + "\""; } } else { From 4e323908fd7d47376b1ec93a2bad59190d2e9896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bedn=C3=A1=C5=99?= Date: Tue, 7 May 2024 10:20:06 +0200 Subject: [PATCH 5/6] fix: code style --- .../query/dsl/functions/restriction/RestrictionsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java b/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java index ab7628e7609..149416be1a9 100644 --- a/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java +++ b/flux-dsl/src/test/java/com/influxdb/query/dsl/functions/restriction/RestrictionsTest.java @@ -75,7 +75,7 @@ void contains() { } @Test - void custom(){ + void custom (){ Restrictions restrictions = Restrictions.value().custom("/.*target.*/", "=~"); Assertions.assertThat(restrictions.toString()).isEqualTo("r[\"_value\"] =~ /.*target.*/"); From 229cfa6d41cb7095aa973071ce768c3f033cd10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bedn=C3=A1=C5=99?= Date: Tue, 7 May 2024 10:51:42 +0200 Subject: [PATCH 6/6] docs: Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb3a319df8..a5812726e6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ 1. [#684](https://github.com/influxdata/influxdb-client-java/issues/684): Fix checking for CSV end of table marker when parsing CSV stream to InfluxQLQueryResult, needed for example when parsing the results of a query like "SHOW SERIES". 2. [#662](https://github.com/influxdata/influxdb-client-java/issues/662): Adds to FluxDsl support for the `|> elapsed(unit)` function. 3. [#623](https://github.com/influxdata/influxdb-client-java/issues/623): Enables the use of IPv6 addresses. -4. [#604](https://github.com/influxdata/influxdb-client-java/issues/604): custom function operator comparison bug fix +4. [#604](https://github.com/influxdata/influxdb-client-java/issues/604): Custom FluxDSL restrictions for regular expressions ### Dependencies