You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/08/15 06:39:18 UTC

[iotdb] branch issue6987 created (now e69aaa6825)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a change to branch issue6987
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at e69aaa6825 [ISSUE-6987] Fix select error when selecting a single quotation mark

This branch includes the following new commits:

     new e69aaa6825 [ISSUE-6987] Fix select error when selecting a single quotation mark

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: [ISSUE-6987] Fix select error when selecting a single quotation mark

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch issue6987
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit e69aaa68259bd83f90c8717f3029d02e9500620e
Author: HTHou <hh...@outlook.com>
AuthorDate: Mon Aug 15 14:39:02 2022 +0800

    [ISSUE-6987] Fix select error when selecting a single quotation mark
---
 .../IoTDBQueryWithComplexValueFilterIT.java        | 33 ++++++++++++++++++++++
 .../db/qp/logical/crud/BasicFunctionOperator.java  |  5 ++--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBQueryWithComplexValueFilterIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBQueryWithComplexValueFilterIT.java
index 4cb9c91e8c..c57334991e 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBQueryWithComplexValueFilterIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBQueryWithComplexValueFilterIT.java
@@ -94,6 +94,39 @@ public class IoTDBQueryWithComplexValueFilterIT {
     }
   }
 
+  @Test
+  public void testRawQuery3() {
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement()) {
+      statement.execute("insert into root.sg1.d1(time,s3) values(1,'\"')");
+      boolean hasResultSet = statement.execute("select * from root.sg1.d1 where s3=\"\\\"\"");
+      Assert.assertTrue(hasResultSet);
+
+      try (ResultSet resultSet = statement.getResultSet()) {
+        int cnt = 0;
+        while (resultSet.next()) {
+          cnt++;
+        }
+        Assert.assertEquals(1, cnt);
+      }
+
+      hasResultSet = statement.execute("select * from root.sg1.d1 where s3=\'\\\"\'");
+      Assert.assertTrue(hasResultSet);
+
+      try (ResultSet resultSet = statement.getResultSet()) {
+        int cnt = 0;
+        while (resultSet.next()) {
+          cnt++;
+        }
+        Assert.assertEquals(1, cnt);
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+
   private static void prepareData() {
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java
index f514a7fe79..9665fbc9e7 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/logical/crud/BasicFunctionOperator.java
@@ -105,8 +105,9 @@ public class BasicFunctionOperator extends FunctionOperator {
           ret =
               funcToken.getUnaryExpression(
                   singlePath,
-                  (value.startsWith("'") && value.endsWith("'"))
-                          || (value.startsWith("\"") && value.endsWith("\""))
+                  value.length() != 1
+                          && ((value.startsWith("'") && value.endsWith("'"))
+                              || (value.startsWith("\"") && value.endsWith("\"")))
                       ? new Binary(value.substring(1, value.length() - 1))
                       : new Binary(value));
         } else {