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 be639f1 fixed: cipherColumn alias in subqueryTable (#13973)
be639f1 is described below
commit be639f1a1fd9c7dda967897fb33ad8cf8d062b82
Author: cheese8 <[email protected]>
AuthorDate: Tue Dec 7 16:12:45 2021 +0800
fixed: cipherColumn alias in subqueryTable (#13973)
---
.../token/generator/impl/EncryptProjectionTokenGenerator.java | 2 +-
.../scenario/encrypt/case/select_for_query_with_cipher.xml | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptProjectionTokenGenerator.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptProjectionTokenGenerator.java
index fab3e26..31ec7d2 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptProjectionTokenGenerator.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptProjectionTokenGenerator.java
@@ -173,7 +173,7 @@ public final class EncryptProjectionTokenGenerator extends
BaseEncryptSQLTokenGe
private Collection<ColumnProjection>
generateTableSubqueryProjections(final String tableName, final ColumnProjection
column) {
Collection<ColumnProjection> result = new LinkedList<>();
- result.add(new ColumnProjection(column.getOwner(),
getEncryptRule().getCipherColumn(tableName, column.getName()),
column.getAlias().orElse(column.getName())));
+ result.add(new ColumnProjection(column.getOwner(),
getEncryptRule().getCipherColumn(tableName, column.getName()), null));
Optional<String> assistedQueryColumn =
getEncryptRule().findAssistedQueryColumn(tableName, column.getName());
assistedQueryColumn.ifPresent(optional -> result.add(new
ColumnProjection(column.getOwner(), optional, null)));
Optional<String> plainColumn =
getEncryptRule().findPlainColumn(tableName, column.getName());
diff --git
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/select_for_query_with_cipher.xml
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/select_for_query_with_cipher.xml
index acfdaf3..4206c61 100644
---
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/select_for_query_with_cipher.xml
+++
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/select_for_query_with_cipher.xml
@@ -101,12 +101,17 @@
<rewrite-assertion id="select_not_nested_subquery_in_table_segment"
db-types="MySQL">
<input sql="SELECT u.amount, u.password, o.certificate_number FROM
(SELECT certificate_number FROM t_account) o, t_account u WHERE
o.certificate_number=u.certificate_number AND u.password=?" parameters="1" />
- <output sql="SELECT u.cipher_amount AS amount, u.cipher_password AS
password, o.cipher_certificate_number AS certificate_number FROM (SELECT
cipher_certificate_number AS certificate_number,
assisted_query_certificate_number FROM t_account) o, t_account u WHERE
o.assisted_query_certificate_number=u.assisted_query_certificate_number AND
u.assisted_query_password=?" parameters="assisted_query_1" />
+ <output sql="SELECT u.cipher_amount AS amount, u.cipher_password AS
password, o.cipher_certificate_number AS certificate_number FROM (SELECT
cipher_certificate_number, assisted_query_certificate_number FROM t_account) o,
t_account u WHERE
o.assisted_query_certificate_number=u.assisted_query_certificate_number AND
u.assisted_query_password=?" parameters="assisted_query_1" />
+ </rewrite-assertion>
+
+ <rewrite-assertion id="select_not_nested_subquery_in_table_segment_refed"
db-types="MySQL">
+ <input sql="SELECT u.amount, u.password, o.certificate_number FROM
(SELECT certificate_number FROM t_account_bak) o, t_account u WHERE
o.certificate_number=u.certificate_number AND u.password=?" parameters="1" />
+ <output sql="SELECT u.cipher_amount AS amount, u.cipher_password AS
password, o.cipher_certificate_number AS certificate_number FROM (SELECT
cipher_certificate_number, assisted_query_certificate_number,
plain_certificate_number FROM t_account_bak) o, t_account u WHERE
o.assisted_query_certificate_number=u.assisted_query_certificate_number AND
u.assisted_query_password=?" parameters="assisted_query_1" />
</rewrite-assertion>
<rewrite-assertion
id="select_not_nested_subquery_in_table_segment_with_shorthand_project"
db-types="MySQL">
<input sql="SELECT u.amount, u.password, o.certificate_number FROM
(SELECT * FROM t_account) o, t_account u WHERE
o.certificate_number=u.certificate_number AND u.password=?" parameters="1" />
- <output sql="SELECT u.cipher_amount AS amount, u.cipher_password AS
password, o.cipher_certificate_number AS certificate_number FROM (SELECT
`t_account`.`account_id`, `t_account`.`cipher_certificate_number` AS
`certificate_number`, `t_account`.`assisted_query_certificate_number`,
`t_account`.`cipher_password` AS `password`,
`t_account`.`assisted_query_password`, `t_account`.`cipher_amount` AS `amount`,
`t_account`.`status` FROM t_account) o, t_account u WHERE o.assisted_query_cer
[...]
+ <output sql="SELECT u.cipher_amount AS amount, u.cipher_password AS
password, o.cipher_certificate_number AS certificate_number FROM (SELECT
`t_account`.`account_id`, `t_account`.`cipher_certificate_number`,
`t_account`.`assisted_query_certificate_number`, `t_account`.`cipher_password`,
`t_account`.`assisted_query_password`, `t_account`.`cipher_amount`,
`t_account`.`status` FROM t_account) o, t_account u WHERE
o.assisted_query_certificate_number=u.assisted_query_certificate_numbe [...]
</rewrite-assertion>
<rewrite-assertion
id="select_not_nested_subquery_in_predicate_right_equal_condition"
db-types="MySQL">