From 7e0b71fc74c06bff49a65cc40db425c6950bdc11 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Thu, 21 Nov 2024 15:10:59 +0800 Subject: [PATCH] Add QuoteCharacter.unwrapText() (#33753) * Add QuoteCharacter.unwrapText() * Add QuoteCharacter.unwrapText() --- .../core/EncryptDistSQLStatementVisitor.java | 3 ++- .../core/MaskDistSQLStatementVisitor.java | 3 ++- ...writeSplittingDistSQLStatementVisitor.java | 3 ++- .../core/ShadowDistSQLStatementVisitor.java | 3 ++- .../core/ShardingDistSQLStatementVisitor.java | 3 ++- .../database/enums/QuoteCharacter.java | 27 ++++++++++++++++--- .../database/enums/QuoteCharacterTest.java | 11 ++++++++ .../core/CDCDistSQLStatementVisitor.java | 7 ++--- .../MigrationDistSQLStatementVisitor.java | 3 ++- .../GlobalClockDistSQLStatementVisitor.java | 3 ++- .../SQLTranslatorDistSQLStatementVisitor.java | 3 ++- .../TransactionDistSQLStatementVisitor.java | 3 ++- .../kernel/KernelDistSQLStatementVisitor.java | 5 ++-- .../value/identifier/IdentifierValue.java | 2 +- 14 files changed, 61 insertions(+), 18 deletions(-) diff --git a/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java b/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java index 7fc4635311075..75bd81c31afc8 100644 --- a/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java +++ b/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java @@ -42,6 +42,7 @@ import org.apache.shardingsphere.encrypt.distsql.statement.CreateEncryptRuleStatement; import org.apache.shardingsphere.encrypt.distsql.statement.DropEncryptRuleStatement; import org.apache.shardingsphere.encrypt.distsql.statement.ShowEncryptRulesStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.DatabaseSegment; @@ -120,7 +121,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java index 4bd4410690c8d..217d10ef84b16 100644 --- a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java +++ b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java @@ -34,6 +34,7 @@ import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; import org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.mask.distsql.segment.MaskColumnSegment; import org.apache.shardingsphere.mask.distsql.segment.MaskRuleSegment; import org.apache.shardingsphere.mask.distsql.statement.AlterMaskRuleStatement; @@ -104,7 +105,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java b/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java index 9d4050754b74f..c1d1cd5878f45 100644 --- a/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java +++ b/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java @@ -33,6 +33,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ShowStatusFromReadwriteSplittingRulesContext; import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; import org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.readwritesplitting.distsql.segment.ReadwriteSplittingRuleSegment; import org.apache.shardingsphere.readwritesplitting.distsql.statement.AlterReadwriteSplittingRuleStatement; import org.apache.shardingsphere.readwritesplitting.distsql.statement.AlterReadwriteSplittingStorageUnitStatusStatement; @@ -121,7 +122,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java b/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java index f8eb9a9d0ecc4..31802ff6d19bc 100644 --- a/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java +++ b/features/shadow/distsql/parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java @@ -40,6 +40,7 @@ import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; import org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.shadow.distsql.segment.ShadowAlgorithmSegment; import org.apache.shardingsphere.shadow.distsql.segment.ShadowRuleSegment; import org.apache.shardingsphere.shadow.distsql.statement.AlterDefaultShadowAlgorithmStatement; @@ -117,7 +118,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java b/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java index 9a0b108b862b9..ac4f808d99400 100644 --- a/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java +++ b/features/sharding/distsql/parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java @@ -66,6 +66,7 @@ import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; import org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sharding.distsql.segment.strategy.AuditStrategySegment; import org.apache.shardingsphere.sharding.distsql.segment.strategy.KeyGenerateStrategySegment; import org.apache.shardingsphere.sharding.distsql.segment.strategy.ShardingAuditorSegment; @@ -311,7 +312,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java index 7cd9cd003742f..501c5de34b7f7 100644 --- a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java +++ b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java @@ -47,10 +47,9 @@ public enum QuoteCharacter { static { for (QuoteCharacter each : values()) { - if (NONE == each) { - continue; + if (NONE != each) { + BY_FIRST_CHAR.put(each.startDelimiter.charAt(0), each); } - BY_FIRST_CHAR.put(each.startDelimiter.charAt(0), each); } } @@ -97,4 +96,26 @@ public String unwrap(final String value) { public boolean isWrapped(final String value) { return value.startsWith(startDelimiter) && value.endsWith(endDelimiter); } + + /** + * Unwrap text. + * + * @param text text to be unwrapped + * @return unwrapped text + */ + public static String unwrapText(final String text) { + return QuoteCharacter.getQuoteCharacter(text).unwrap(text); + } + + /** + * Unwrap and trim text. + * + * @param text text to be unwrapped and trimmed + * @return unwrapped and trimmed test + */ + // TODO Should use unwrap instead of this method after new rules defined in G4's property key and property key, which should include string but cannot permit blank on first and last of the value + // TODO @longtao + public static String unwrapAndTrimText(final String text) { + return unwrapText(text).trim(); + } } diff --git a/infra/database/core/src/test/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacterTest.java b/infra/database/core/src/test/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacterTest.java index f29fff4d3c821..87a010eee304c 100644 --- a/infra/database/core/src/test/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacterTest.java +++ b/infra/database/core/src/test/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacterTest.java @@ -85,4 +85,15 @@ void assertIsWrapped() { void assertIsNotWrapped() { assertFalse(QuoteCharacter.SINGLE_QUOTE.isWrapped("'test\"")); } + + @Test + void assertUnwrapText() { + assertThat(QuoteCharacter.unwrapText("test"), is("test")); + assertThat(QuoteCharacter.unwrapText("`test`"), is("test")); + assertThat(QuoteCharacter.unwrapText("'test'"), is("test")); + assertThat(QuoteCharacter.unwrapText("\"test\""), is("test")); + assertThat(QuoteCharacter.unwrapText("[test]"), is("test")); + assertThat(QuoteCharacter.unwrapText("(test)"), is("test")); + assertThat(QuoteCharacter.unwrapText("{test}"), is("{test}")); + } } diff --git a/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/parser/core/CDCDistSQLStatementVisitor.java b/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/parser/core/CDCDistSQLStatementVisitor.java index 1c939da7d0595..4e0b562be5421 100644 --- a/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/parser/core/CDCDistSQLStatementVisitor.java +++ b/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/parser/core/CDCDistSQLStatementVisitor.java @@ -18,10 +18,11 @@ package org.apache.shardingsphere.data.pipeline.cdc.distsql.parser.core; import org.antlr.v4.runtime.tree.ParseTree; -import org.apache.shardingsphere.data.pipeline.cdc.distsql.statement.updatable.DropStreamingStatement; import org.apache.shardingsphere.data.pipeline.cdc.distsql.statement.queryable.ShowStreamingListStatement; import org.apache.shardingsphere.data.pipeline.cdc.distsql.statement.queryable.ShowStreamingRuleStatement; import org.apache.shardingsphere.data.pipeline.cdc.distsql.statement.queryable.ShowStreamingStatusStatement; +import org.apache.shardingsphere.data.pipeline.cdc.distsql.statement.updatable.DropStreamingStatement; +import org.apache.shardingsphere.data.pipeline.distsql.statement.updatable.AlterTransmissionRuleStatement; import org.apache.shardingsphere.distsql.parser.autogen.CDCDistSQLStatementBaseVisitor; import org.apache.shardingsphere.distsql.parser.autogen.CDCDistSQLStatementParser.AlgorithmDefinitionContext; import org.apache.shardingsphere.distsql.parser.autogen.CDCDistSQLStatementParser.AlterStreamingRuleContext; @@ -42,7 +43,7 @@ import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; import org.apache.shardingsphere.distsql.segment.ReadOrWriteSegment; import org.apache.shardingsphere.distsql.segment.TransmissionRuleSegment; -import org.apache.shardingsphere.data.pipeline.distsql.statement.updatable.AlterTransmissionRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; @@ -145,7 +146,7 @@ private Properties buildProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java b/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java index a3a17442a4262..9647671844271 100644 --- a/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java +++ b/kernel/data-pipeline/distsql/parser/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java @@ -79,6 +79,7 @@ import org.apache.shardingsphere.distsql.segment.URLBasedDataSourceSegment; import org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement; import org.apache.shardingsphere.data.pipeline.distsql.statement.updatable.AlterTransmissionRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.infra.datanode.DataNode; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; @@ -250,7 +251,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/kernel/global-clock/distsql/parser/src/main/java/org/apache/shardingsphere/globalclock/distsql/parser/core/GlobalClockDistSQLStatementVisitor.java b/kernel/global-clock/distsql/parser/src/main/java/org/apache/shardingsphere/globalclock/distsql/parser/core/GlobalClockDistSQLStatementVisitor.java index ce5c55c659ff3..71ca6c7cc97e5 100644 --- a/kernel/global-clock/distsql/parser/src/main/java/org/apache/shardingsphere/globalclock/distsql/parser/core/GlobalClockDistSQLStatementVisitor.java +++ b/kernel/global-clock/distsql/parser/src/main/java/org/apache/shardingsphere/globalclock/distsql/parser/core/GlobalClockDistSQLStatementVisitor.java @@ -26,6 +26,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.GlobalClockDistSQLStatementParser.ShowGlobalClockRuleContext; import org.apache.shardingsphere.globalclock.distsql.statement.queryable.ShowGlobalClockRuleStatement; import org.apache.shardingsphere.globalclock.distsql.statement.updatable.AlterGlobalClockRuleStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; @@ -59,7 +60,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java b/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java index df387050617c4..3791f56b71cda 100644 --- a/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java +++ b/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java @@ -26,6 +26,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementParser.ShowSQLTranslatorRuleContext; import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementParser.UseOriginalSQLDefinitionContext; import org.apache.shardingsphere.distsql.segment.AlgorithmSegment; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; @@ -61,7 +62,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/kernel/transaction/distsql/parser/src/main/java/org/apache/shardingsphere/transaction/distsql/parser/core/TransactionDistSQLStatementVisitor.java b/kernel/transaction/distsql/parser/src/main/java/org/apache/shardingsphere/transaction/distsql/parser/core/TransactionDistSQLStatementVisitor.java index 7be7e46d5209f..3240f32da4453 100644 --- a/kernel/transaction/distsql/parser/src/main/java/org/apache/shardingsphere/transaction/distsql/parser/core/TransactionDistSQLStatementVisitor.java +++ b/kernel/transaction/distsql/parser/src/main/java/org/apache/shardingsphere/transaction/distsql/parser/core/TransactionDistSQLStatementVisitor.java @@ -25,6 +25,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.TransactionDistSQLStatementParser.ProviderDefinitionContext; import org.apache.shardingsphere.distsql.parser.autogen.TransactionDistSQLStatementParser.ShowTransactionRuleContext; import org.apache.shardingsphere.distsql.parser.autogen.TransactionDistSQLStatementParser.TransactionRuleDefinitionContext; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; @@ -66,7 +67,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java index 4968e9b360cdb..52f1886e1a472 100644 --- a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java +++ b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java @@ -95,6 +95,7 @@ import org.apache.shardingsphere.distsql.statement.rql.resource.ShowLogicalTablesStatement; import org.apache.shardingsphere.distsql.statement.rql.resource.ShowStorageUnitsStatement; import org.apache.shardingsphere.distsql.statement.rql.rule.database.ShowRulesUsedStorageUnitStatement; +import org.apache.shardingsphere.infra.database.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.DatabaseSegment; @@ -203,7 +204,7 @@ private Properties getProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } @@ -318,7 +319,7 @@ private Properties buildProperties(final PropertiesDefinitionContext ctx) { return result; } for (PropertyContext each : ctx.properties().property()) { - result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + result.setProperty(QuoteCharacter.unwrapAndTrimText(each.key.getText()), QuoteCharacter.unwrapAndTrimText(each.value.getText())); } return result; } diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/identifier/IdentifierValue.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/identifier/IdentifierValue.java index 9c342e7deb0df..beed7c43aa8bc 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/identifier/IdentifierValue.java +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/identifier/IdentifierValue.java @@ -63,6 +63,6 @@ public String getValueWithQuoteCharacters() { * @return quote content */ public static String getQuotedContent(final String text) { - return Strings.isNullOrEmpty(text) ? text : QuoteCharacter.getQuoteCharacter(text).unwrap(text).trim(); + return Strings.isNullOrEmpty(text) ? text : QuoteCharacter.unwrapAndTrimText(text); } }