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

zhaojinchao 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 4496275e697 Refactor MissingRequiredEncryptColumnException (#30847)
4496275e697 is described below

commit 4496275e69745fe1eaf02e30d3d20d7096baf040
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Apr 11 13:13:53 2024 +0800

    Refactor MissingRequiredEncryptColumnException (#30847)
---
 docs/document/content/user-manual/error-code/sql-error-code.cn.md | 2 +-
 docs/document/content/user-manual/error-code/sql-error-code.en.md | 2 +-
 .../encrypt/checker/EncryptRuleConfigurationChecker.java          | 8 +++++---
 .../exception/metadata/MissingRequiredEncryptColumnException.java | 5 +++--
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index a8a745dff53..e9b0ed33ee3 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -216,7 +216,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 | Vendor Code | SQL State | 错误信息                                               
                                          |
 
|-------------|-----------|----------------------------------------------------------------------------------------------|
-| 21000       | 42S02     | %s column '%s' is required in database '%s'.       
                                          |
+| 21000       | 42S02     | %s column is required in %s.                       
                                          |
 | 21001       | 42S02     | Can not find encrypt table '%s'.                   
                                          |
 | 21002       | 42S02     | Can not find logic encrypt column by '%s'.         
                                          |
 | 21003       | 42S02     | Can not find encrypt column '%s' from table '%s'.  
                                          |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index ca16ff8ab12..71a446f9560 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -217,7 +217,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 
 | Vendor Code | SQL State | Reason                                             
                                          |
 
|-------------|-----------|----------------------------------------------------------------------------------------------|
-| 21000       | 42S02     | %s column '%s' is required in database '%s'.       
                                          |
+| 21000       | 42S02     | %s column is required in %s.                       
                                          |
 | 21001       | 42S02     | Can not find encrypt table '%s'.                   
                                          |
 | 21002       | 42S02     | Can not find logic encrypt column by '%s'.         
                                          |
 | 21003       | 42S02     | Can not find encrypt column '%s' from table '%s'.  
                                          |
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
index 8613e2ceaf0..839dce5326f 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
@@ -70,7 +70,8 @@ public final class EncryptRuleConfigurationChecker implements 
RuleConfigurationC
     
     private void checkCipherColumn(final String databaseName, final String 
tableName, final String logicColumnName,
                                    final EncryptColumnItemRuleConfiguration 
cipherColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
-        
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getName()),
 () -> new MissingRequiredEncryptColumnException("Cipher", logicColumnName, 
databaseName));
+        
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getName()),
+                () -> new MissingRequiredEncryptColumnException("Cipher", new 
SQLExceptionIdentifier(databaseName, tableName, logicColumnName)));
         
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getEncryptorName()),
                 () -> new EmptyAlgorithmException("Standard encrypt", new 
SQLExceptionIdentifier(databaseName, tableName, logicColumnName)));
         
ShardingSpherePreconditions.checkState(encryptors.containsKey(cipherColumnConfig.getEncryptorName()),
@@ -80,7 +81,7 @@ public final class EncryptRuleConfigurationChecker implements 
RuleConfigurationC
     private void checkAssistColumn(final String databaseName, final String 
tableName, final String logicColumnName,
                                    final EncryptColumnItemRuleConfiguration 
assistedQueryColumnConfig, final Map<String, AlgorithmConfiguration> 
encryptors) {
         
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getName()),
-                () -> new MissingRequiredEncryptColumnException("Assisted 
query", logicColumnName, databaseName));
+                () -> new MissingRequiredEncryptColumnException("Assisted 
query", new SQLExceptionIdentifier(databaseName, tableName, logicColumnName)));
         
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getEncryptorName()),
                 () -> new EmptyAlgorithmException("Assist query encrypt", new 
SQLExceptionIdentifier(databaseName, tableName, logicColumnName)));
         
ShardingSpherePreconditions.checkState(encryptors.containsKey(assistedQueryColumnConfig.getEncryptorName()),
@@ -89,7 +90,8 @@ public final class EncryptRuleConfigurationChecker implements 
RuleConfigurationC
     
     private void checkLikeColumn(final String databaseName, final String 
tableName, final String logicColumnName,
                                  final EncryptColumnItemRuleConfiguration 
likeQueryColumnConfig, final Map<String, AlgorithmConfiguration> encryptors) {
-        
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getName()),
 () -> new MissingRequiredEncryptColumnException("Like", logicColumnName, 
databaseName));
+        
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getName()),
+                () -> new MissingRequiredEncryptColumnException("Like", new 
SQLExceptionIdentifier(databaseName, tableName, logicColumnName)));
         
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getEncryptorName()),
                 () -> new EmptyAlgorithmException("Like query", new 
SQLExceptionIdentifier(databaseName, tableName, logicColumnName)));
         
ShardingSpherePreconditions.checkState(encryptors.containsKey(likeQueryColumnConfig.getEncryptorName()),
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingRequiredEncryptColumnException.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingRequiredEncryptColumnException.java
index 4b5a79c0990..e5352999a01 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingRequiredEncryptColumnException.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingRequiredEncryptColumnException.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.encrypt.exception.metadata;
 
 import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
+import 
org.apache.shardingsphere.infra.exception.core.external.sql.identifier.SQLExceptionIdentifier;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
 
 /**
@@ -27,7 +28,7 @@ public final class MissingRequiredEncryptColumnException 
extends EncryptSQLExcep
     
     private static final long serialVersionUID = -6765795304282762539L;
     
-    public MissingRequiredEncryptColumnException(final String columnType, 
final String logicColumnName, final String databaseName) {
-        super(XOpenSQLState.NOT_FOUND, 0, "%s column '%s' is required in 
database '%s'.", columnType, logicColumnName, databaseName);
+    public MissingRequiredEncryptColumnException(final String columnType, 
final SQLExceptionIdentifier sqlExceptionIdentifier) {
+        super(XOpenSQLState.NOT_FOUND, 0, "%s column is required in %s.", 
columnType, sqlExceptionIdentifier);
     }
 }

Reply via email to