diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java index 84e804ca88cd0..3aca7bb2326fd 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java @@ -134,7 +134,7 @@ public boolean isCipherColumn(final String columnName) { public String getLogicColumnByCipherColumn(final String cipherColumnName) { for (Entry entry : columns.entrySet()) { if (entry.getValue().getCipher().getName().equalsIgnoreCase(cipherColumnName)) { - return entry.getKey(); + return entry.getValue().getName(); } } throw new EncryptLogicColumnNotFoundException(cipherColumnName); diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java index b12f434351b66..8442ec305ef28 100644 --- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java +++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java @@ -80,7 +80,7 @@ void assertIsEncryptColumn() { @Test void assertGetLogicColumnByCipherColumn() { - assertNotNull(encryptTable.getLogicColumnByCipherColumn("cipherColumn")); + assertThat(encryptTable.getLogicColumnByCipherColumn("cipherColumn"), is("logicColumn")); } @Test