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

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 01c0e89bf2b Fix like query bug in PostgreSQLStatementSQLVisitor.java 
and OpenGaussStatementSQLVisitor.java (#25033)
01c0e89bf2b is described below

commit 01c0e89bf2beaa898412e64bea302d46534f6e2c
Author: wangtiga <[email protected]>
AuthorDate: Wed Apr 12 20:02:39 2023 +0800

    Fix like query bug in PostgreSQLStatementSQLVisitor.java and 
OpenGaussStatementSQLVisitor.java (#25033)
    
    * Fix like query bug in PostgreSQLStatementSQLVisitor.java
    
    * Fix like query bug in OpenGaussStatementSQLVisitor.java
---
 .../visitor/statement/impl/OpenGaussStatementSQLVisitor.java          | 2 +-
 .../visitor/statement/impl/PostgreSQLStatementSQLVisitor.java         | 2 +-
 .../encrypt/case/query-with-cipher/dml/select/select-where.xml        | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/sql-parser/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
 
b/sql-parser/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
index 970c53d51da..d968196fda7 100644
--- 
a/sql-parser/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
+++ 
b/sql-parser/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussStatementSQLVisitor.java
@@ -350,7 +350,7 @@ public abstract class OpenGaussStatementSQLVisitor extends 
OpenGaussStatementBas
     }
     
     private BinaryOperationExpression 
createPatternMatchingOperationSegment(final AExprContext ctx) {
-        String operator = getOriginalText(ctx.patternMatchingOperator());
+        String operator = 
getOriginalText(ctx.patternMatchingOperator()).toUpperCase();
         ExpressionSegment left = (ExpressionSegment) visit(ctx.aExpr(0));
         ListExpression right = new 
ListExpression(ctx.aExpr(1).start.getStartIndex(), 
ctx.aExpr().get(ctx.aExpr().size() - 1).stop.getStopIndex());
         for (int i = 1; i < ctx.aExpr().size(); i++) {
diff --git 
a/sql-parser/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
 
b/sql-parser/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
index 5fb422b6fb5..bf7711aaebf 100644
--- 
a/sql-parser/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
+++ 
b/sql-parser/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLStatementSQLVisitor.java
@@ -350,7 +350,7 @@ public abstract class PostgreSQLStatementSQLVisitor extends 
PostgreSQLStatementP
     }
     
     private BinaryOperationExpression 
createPatternMatchingOperationSegment(final AExprContext ctx) {
-        String operator = getOriginalText(ctx.patternMatchingOperator());
+        String operator = 
getOriginalText(ctx.patternMatchingOperator()).toUpperCase();
         ExpressionSegment left = (ExpressionSegment) visit(ctx.aExpr(0));
         ListExpression right = new 
ListExpression(ctx.aExpr(1).start.getStartIndex(), 
ctx.aExpr().get(ctx.aExpr().size() - 1).stop.getStopIndex());
         for (int i = 1; i < ctx.aExpr().size(); i++) {
diff --git 
a/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/select/select-where.xml
 
b/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/select/select-where.xml
index 002d81f3f79..5db6d3d833e 100644
--- 
a/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/select/select-where.xml
+++ 
b/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/select/select-where.xml
@@ -17,12 +17,12 @@
   -->
 
 <rewrite-assertions yaml-rule="scenario/encrypt/config/query-with-cipher.yaml">
-    <rewrite-assertion id="select_for_parameters" db-types="MySQL">
+    <rewrite-assertion id="select_for_parameters" 
db-types="MySQL,PostgreSQL,openGauss">
         <input sql="SELECT account_id, password, amount AS a, status AS s FROM 
t_account WHERE account_id = ? AND password = ? AND password like ? AND amount 
= ? AND status = ?" parameters="1, aaa, aaa, 1000, OK" />
         <output sql="SELECT account_id, cipher_password AS password, 
cipher_amount AS a, status AS s FROM t_account WHERE account_id = ? AND 
assisted_query_password = ? AND like_query_password like ? AND cipher_amount = 
? AND status = ?" parameters="1, assisted_query_aaa, like_query_aaa, 
encrypt_1000, OK" />
     </rewrite-assertion>
     
-    <rewrite-assertion id="select_for_literals" db-types="MySQL">
+    <rewrite-assertion id="select_for_literals" 
db-types="MySQL,PostgreSQL,openGauss">
         <input sql="SELECT account_id, password, amount AS a, status AS s FROM 
t_account WHERE account_id = 1 AND password = 'aaa' AND password like 'aaa' AND 
amount = 1000 AND status = 'OK'" />
         <output sql="SELECT account_id, cipher_password AS password, 
cipher_amount AS a, status AS s FROM t_account WHERE account_id = 1 AND 
assisted_query_password = 'assisted_query_aaa' AND like_query_password like 
'like_query_aaa' AND cipher_amount = 'encrypt_1000' AND status = 'OK'" />
     </rewrite-assertion>

Reply via email to