This is an automated email from the ASF dual-hosted git repository. zhangliang 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 c1db97aee3b Revert "Refactor ColumnProjection.getColumnName() (#35176)" (#35178) c1db97aee3b is described below commit c1db97aee3bc4cad628d82dc0ce2b4c2446632cb Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Sun Apr 13 13:48:06 2025 +0800 Revert "Refactor ColumnProjection.getColumnName() (#35176)" (#35178) This reverts commit 630f86367aa5be1bd777f3f7d943370c2883b68e. --- .../context/segment/select/projection/impl/ColumnProjection.java | 4 +++- .../segment/select/projection/impl/ColumnProjectionTest.java | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjection.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjection.java index e194d33ebb2..1100bce1984 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjection.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjection.java @@ -26,6 +26,7 @@ import org.apache.shardingsphere.infra.binder.context.segment.select.projection. import org.apache.shardingsphere.infra.binder.context.segment.select.projection.extractor.ProjectionIdentifierExtractEngine; import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; +import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.ParenthesesSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.ColumnSegmentBoundInfo; import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; @@ -120,7 +121,8 @@ public final class ColumnProjection implements Projection { @Override public String getColumnName() { - return new ProjectionIdentifierExtractEngine(databaseType).getIdentifierValue(name); + ProjectionIdentifierExtractEngine extractEngine = new ProjectionIdentifierExtractEngine(databaseType); + return databaseType instanceof MySQLDatabaseType ? extractEngine.getIdentifierValue(name) : getColumnLabel(); } @Override diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjectionTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjectionTest.java index 19539ae5295..4312e963854 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjectionTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/ColumnProjectionTest.java @@ -89,10 +89,16 @@ class ColumnProjectionTest { } @Test - void assertGetColumnNameWithAlias() { + void assertGetColumnNameWithMySQL() { + DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "MySQL"); assertThat(new ColumnProjection(null, "name", "alias", databaseType).getColumnName(), is("name")); } + @Test + void assertGetColumnNameWithAlias() { + assertThat(new ColumnProjection(null, "name", "alias", databaseType).getColumnName(), is("alias")); + } + @Test void assertGetColumnNameWithoutAlias() { assertThat(new ColumnProjection(null, "name", null, databaseType).getColumnName(), is("name"));