You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2026/09/24 03:54:51 UTC
(shardingsphere) branch master updated: Minor refactor in MD5AssistedEncryptAlgorithm and ProjectionsSegmentBinder (#39944)
This is an automated email from the ASF dual-hosted git repository.
FlyingZC 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 5d1a6fc6e31 Minor refactor in MD5AssistedEncryptAlgorithm and ProjectionsSegmentBinder (#39944)
5d1a6fc6e31 is described below
commit 5d1a6fc6e31bf794764a28897c7fa25a80de90c0
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Thu Sep 24 11:54:44 2026 +0800
Minor refactor in MD5AssistedEncryptAlgorithm and ProjectionsSegmentBinder (#39944)
---
.../algorithm/assisted/MD5AssistedEncryptAlgorithm.java | 4 +---
.../assisted/MD5AssistedEncryptAlgorithmTest.java | 3 ++-
.../segment/dml/projection/ProjectionsSegmentBinder.java | 15 +++++++++++++++
.../core/segment/dml/item/ProjectionsSegment.java | 3 +++
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
index 161980a7b4d..272b63cea72 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
@@ -90,9 +90,7 @@ public final class MD5AssistedEncryptAlgorithm implements EncryptAlgorithm {
@Override
public AlgorithmConfiguration toConfiguration() {
Properties result = PropertiesBuilder.build(new Property(SALT_KEY, props.getProperty(SALT_KEY, "")));
- if (props.containsKey(MD5_ENCODER)) {
- result.setProperty(MD5_ENCODER, md5Encoder);
- }
+ result.setProperty(MD5_ENCODER, md5Encoder);
return new AlgorithmConfiguration(getType(), result);
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithmTest.java
index 251978427d1..fc9a783a608 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithmTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithmTest.java
@@ -67,8 +67,9 @@ class MD5AssistedEncryptAlgorithmTest {
void assertToConfiguration() {
AlgorithmConfiguration actual = encryptAlgorithm.toConfiguration();
assertThat(actual.getType(), is("MD5"));
- assertThat(actual.getProps().size(), is(1));
+ assertThat(actual.getProps().size(), is(2));
assertThat(actual.getProps().getProperty("salt"), is(""));
+ assertThat(actual.getProps().getProperty("md5-encoder"), is("HEX"));
}
@Test
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/projection/ProjectionsSegmentBinder.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/projection/ProjectionsSegmentBinder.java
index f560fea0c70..a60385cdb54 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/projection/ProjectionsSegmentBinder.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/projection/ProjectionsSegmentBinder.java
@@ -80,6 +80,10 @@ public final class ProjectionsSegmentBinder {
Multimap<CaseInsensitiveString, TableSegmentBinderContext> currentTableBinderContexts = createCurrentTableBinderContexts(binderContext, result.getProjections());
result.getProjections().add(bind(binderContext, boundTableSegment, currentTableBinderContexts, tableBinderContexts, outerTableBinderContexts, each));
}
+ Multimap<CaseInsensitiveString, TableSegmentBinderContext> currentTableBinderContexts = createCurrentTableBinderContexts(binderContext, result.getProjections());
+ for (ExpressionSegment each : segment.getDistinctOnItems()) {
+ result.getDistinctOnItems().add(bindDistinctOnItem(each, binderContext, currentTableBinderContexts, tableBinderContexts, outerTableBinderContexts));
+ }
return result;
}
@@ -134,6 +138,17 @@ public final class ProjectionsSegmentBinder {
return projectionSegment;
}
+ private static ExpressionSegment bindDistinctOnItem(final ExpressionSegment segment, final SQLStatementBinderContext binderContext,
+ final Multimap<CaseInsensitiveString, TableSegmentBinderContext> currentTableBinderContexts,
+ final Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts,
+ final Multimap<CaseInsensitiveString, TableSegmentBinderContext> outerTableBinderContexts) {
+ try {
+ return ExpressionSegmentBinder.bind(segment, SegmentType.ORDER_BY, binderContext, tableBinderContexts, outerTableBinderContexts);
+ } catch (final ColumnNotFoundException ignored) {
+ return ExpressionSegmentBinder.bind(segment, SegmentType.ORDER_BY, binderContext, currentTableBinderContexts, outerTableBinderContexts);
+ }
+ }
+
private static AggregationDistinctProjectionSegment bindAggregationDistinctProjection(final AggregationDistinctProjectionSegment aggregationDistinctSegment,
final SQLStatementBinderContext binderContext,
final Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts,
diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/item/ProjectionsSegment.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/item/ProjectionsSegment.java
index f76f5805334..020ce323d3e 100644
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/item/ProjectionsSegment.java
+++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/item/ProjectionsSegment.java
@@ -21,6 +21,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment;
import java.util.LinkedList;
import java.util.List;
@@ -38,6 +39,8 @@ public final class ProjectionsSegment implements SQLSegment {
private final List<ProjectionSegment> projections = new LinkedList<>();
+ private final List<ExpressionSegment> distinctOnItems = new LinkedList<>();
+
@Setter
private boolean distinctRow;
}