We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org.apache.shardingsphere shardingsphere-jdbc 5.5.1
org.yaml snakeyaml 2.2
mode: type: Standalone repository: type: JDBC dataSources: unique_ds: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.cj.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/sharding_sphere?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=UTC&useSSL=false username: root password: 123456 rules: - !ENCRYPT tables: user: columns: phone: cipher: name: phone_cipher encryptorName: aes_encryptor id_card_no: cipher: name: id_card_no_cipher encryptorName: aes_encryptor encryptors: aes_encryptor: type: AES props: aes-key-value: 123456abc digest-algorithm-name: SHA-1
create table user ( id bigint auto_increment primary key, name varchar(32) not null comment '姓名', phone varchar(16) null comment '手机号', id_card_no varchar(32) null comment '身份证', phone_cipher varchar(50) null comment '密文手机号', id_card_no_cipher varchar(50) null comment '密文身份证' ) comment '用户' charset = utf8;
@Repository public interface UserRepository extends JpaRepository<UserEntity, Long> { @Query(value = "select distinct phone from user", nativeQuery = true) List<String> listDistinctPhone(); @Query(value = "select *\n" + "from user\n" + "where 1 = 1\n" + " and if(:phone is not null, phone = :phone, 1=1)", nativeQuery = true) List<UserEntity> listByPhoneIfJudge(@Param("phone") String phone); @Query(value = "select count(case when phone is not null then 1 end) total\n" + "from user", nativeQuery = true) Long countPhoneCaseWhen(); }
listByPhoneIfJudge
The expected result is simulated by me after removing the if judgment
@Query(value = "select *\n" + "from user\n" + "where 1 = 1\n" + // " and if(:phone is not null, phone = :phone, 1=1)", " and phone = :phone", nativeQuery = true) List<UserEntity> listByPhoneIfJudge(@Param("phone") String phone);
countPhoneCaseWhen
1. listByPhoneIfJudge method
It seems that in special condition, the encrypted column has not been parsed into a ciphertext column.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
sharding version:
org.apache.shardingsphere
shardingsphere-jdbc
5.5.1
snakeYaml version:
org.yaml
snakeyaml
2.2
sharding.yaml
mysql
db data
search
expected result
listByPhoneIfJudge
methodThe expected result is simulated by me after removing the if judgment
countPhoneCaseWhen
method3
actual result
1.
listByPhoneIfJudge
methodcountPhoneCaseWhen
method1
possible conclusions
It seems that in special condition, the encrypted column has not been parsed into a ciphertext column.
The text was updated successfully, but these errors were encountered: