From 501ef0b416f44bae434e3954e4c9ad4f52ef62af Mon Sep 17 00:00:00 2001 From: codefairy08 Date: Thu, 4 Apr 2019 10:44:39 +0800 Subject: [PATCH 1/2] for encrypt sharding test --- .../impl/EncryptOrConditionFiller.java | 8 +++ .../segment/impl/OrConditionFiller.java | 21 +++++-- .../core/parse/AntlrIntegrateParsingTest.java | 2 +- .../IntegrateDDLParsingCompatibleTest.java | 2 +- .../integrate/asserts/SQLStatementAssert.java | 22 ++++--- .../token/EncryptColumnTokenAssert.java | 14 ++++- .../integrate/asserts/token/TokenAssert.java | 12 +++- .../IntegrateSupportedSQLParsingTest.java | 2 +- .../token/ExpectedEncryptColumnToken.java | 15 +++-- .../src/test/resources/parser/delete.xml | 30 ++++++++++ .../src/test/resources/parser/select.xml | 60 +++++++++++++++++++ .../src/test/resources/parser/select_or.xml | 40 +++++++++++++ .../test/resources/parser/select_order_by.xml | 20 +++++++ .../src/test/resources/parser/update.xml | 21 +++++++ .../src/main/resources/sql/dql/select.xml | 4 +- 15 files changed, 246 insertions(+), 27 deletions(-) diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java index 407f331dc297b..4cf31df607398 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java @@ -36,7 +36,9 @@ import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * Encrypt or condition filler. @@ -77,11 +79,17 @@ private void fillColumnTableMap(final SQLStatement sqlStatement, final ShardingT private OrCondition filterCondition(final ShardingTableMetaData shardingTableMetaData, final SQLStatement sqlStatement, final OrConditionSegment orCondition, final String sql, final EncryptRule encryptRule, final Map columnNameToTable, final Map columnNameCount) { OrCondition result = new OrCondition(); + Set filledConditionStopIndexs = new HashSet(); for (AndConditionSegment each : orCondition.getAndConditions()) { for (ConditionSegment condition : each.getConditions()) { if (null == condition.getColumn()) { continue; } + if(filledConditionStopIndexs.contains(condition.getStopIndex())) { + continue; + }else { + filledConditionStopIndexs.add(condition.getStopIndex()); + } Column column = new Column(condition.getColumn().getName(), getTableName(shardingTableMetaData, sqlStatement, condition)); fillEncryptCondition(column, condition, encryptRule, sqlStatement, sql); } diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java index 1493bb14c512e..a9bb72b44653c 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java @@ -17,7 +17,14 @@ package org.apache.shardingsphere.core.parse.antlr.filler.sharding.segment.impl; -import com.google.common.base.Optional; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.shardingsphere.core.constant.ShardingOperator; import org.apache.shardingsphere.core.metadata.table.ShardingTableMetaData; import org.apache.shardingsphere.core.metadata.table.TableMetaData; @@ -39,11 +46,7 @@ import org.apache.shardingsphere.core.parse.parser.token.TableToken; import org.apache.shardingsphere.core.rule.ShardingRule; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import com.google.common.base.Optional; /** * Or condition filler. @@ -124,6 +127,7 @@ private OrCondition filterCondition( break; } } + Set filledConditionStopIndexs = new HashSet(); for (AndConditionSegment each : orCondition.getAndConditions()) { for (ConditionSegment condition : each.getConditions()) { if (null == condition.getColumn()) { @@ -132,6 +136,11 @@ private OrCondition filterCondition( if (condition.getExpression() instanceof ColumnSegment) { continue; } + if(filledConditionStopIndexs.contains(condition.getStopIndex())) { + continue; + }else { + filledConditionStopIndexs.add(condition.getStopIndex()); + } Column column = new Column(condition.getColumn().getName(), getTableName(shardingTableMetaData, shardingRule, sqlStatement, condition)); fillEncryptCondition(column, condition, shardingRule, sqlStatement, sql); } diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/AntlrIntegrateParsingTest.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/AntlrIntegrateParsingTest.java index 771aa6e865a70..e3b33e3f2fece 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/AntlrIntegrateParsingTest.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/AntlrIntegrateParsingTest.java @@ -91,7 +91,7 @@ public void assertSupportedSQL() { execDatabaseType = DatabaseType.MySQL; } new SQLStatementAssert(new AntlrParsingEngine(execDatabaseType, sql, AbstractBaseIntegrateSQLParsingTest.getShardingRule(), - AbstractBaseIntegrateSQLParsingTest.getShardingTableMetaData()).parse(), sqlCaseId, sqlCaseType, sqlCasesLoader, parserResultSetLoader).assertSQLStatement(); + AbstractBaseIntegrateSQLParsingTest.getShardingTableMetaData()).parse(), sqlCaseId, sqlCaseType, sqlCasesLoader, parserResultSetLoader, execDatabaseType).assertSQLStatement(); } } } diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/ddl/IntegrateDDLParsingCompatibleTest.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/ddl/IntegrateDDLParsingCompatibleTest.java index 8685cb398b22e..32fe528b0a6f1 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/ddl/IntegrateDDLParsingCompatibleTest.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/ddl/IntegrateDDLParsingCompatibleTest.java @@ -85,6 +85,6 @@ public void assertSupportedSQL() { } new SQLStatementAssert(new AntlrParsingEngine( execDatabaseType, sql, AbstractBaseIntegrateSQLParsingTest.getShardingRule(), - AbstractBaseIntegrateSQLParsingTest.getShardingTableMetaData()).parse(), sqlCaseId, sqlCaseType, sqlCasesLoader, parserResultSetLoader).assertSQLStatement(); + AbstractBaseIntegrateSQLParsingTest.getShardingTableMetaData()).parse(), sqlCaseId, sqlCaseType, sqlCasesLoader, parserResultSetLoader, execDatabaseType).assertSQLStatement(); } } diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/SQLStatementAssert.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/SQLStatementAssert.java index 1c7b6daed9696..61a3e6b7b6aad 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/SQLStatementAssert.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/SQLStatementAssert.java @@ -17,6 +17,10 @@ package org.apache.shardingsphere.core.parse.integrate.asserts; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.apache.shardingsphere.core.constant.DatabaseType; import org.apache.shardingsphere.core.parse.antlr.sql.statement.ddl.AlterTableStatement; import org.apache.shardingsphere.core.parse.antlr.sql.statement.ddl.CreateTableStatement; import org.apache.shardingsphere.core.parse.antlr.sql.statement.tcl.TCLStatement; @@ -36,9 +40,6 @@ import org.apache.shardingsphere.test.sql.SQLCaseType; import org.apache.shardingsphere.test.sql.SQLCasesLoader; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - /** * SQL statement assert. * @@ -70,17 +71,19 @@ public final class SQLStatementAssert { private final AlterTableAssert alterTableAssert; - public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, final SQLCaseType sqlCaseType) { - this(actual, sqlCaseId, sqlCaseType, SQLCasesLoader.getInstance(), ParserResultSetLoader.getInstance()); + private final DatabaseType databaseType; + + public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, final SQLCaseType sqlCaseType, final DatabaseType databaseType) { + this(actual, sqlCaseId, sqlCaseType, SQLCasesLoader.getInstance(), ParserResultSetLoader.getInstance(), databaseType); } - public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, final SQLCaseType sqlCaseType, final SQLCasesLoader sqlLoader, final ParserResultSetLoader parserResultSetLoader) { + public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, final SQLCaseType sqlCaseType, final SQLCasesLoader sqlLoader, final ParserResultSetLoader parserResultSetLoader, final DatabaseType databaseType) { SQLStatementAssertMessage assertMessage = new SQLStatementAssertMessage(sqlLoader, parserResultSetLoader, sqlCaseId, sqlCaseType); this.actual = actual; expected = parserResultSetLoader.getParserResult(sqlCaseId); tableAssert = new TableAssert(assertMessage); conditionAssert = new ConditionAssert(assertMessage); - tokenAssert = new TokenAssert(sqlCaseType, assertMessage); + tokenAssert = new TokenAssert(sqlCaseType, assertMessage, databaseType); indexAssert = new IndexAssert(sqlCaseType, assertMessage); itemAssert = new ItemAssert(assertMessage); groupByAssert = new GroupByAssert(assertMessage); @@ -88,6 +91,7 @@ public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, fin limitAssert = new LimitAssert(sqlCaseType, assertMessage); metaAssert = new TableMetaDataAssert(assertMessage); alterTableAssert = new AlterTableAssert(assertMessage); + this.databaseType = databaseType; } /** @@ -96,7 +100,9 @@ public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, fin public void assertSQLStatement() { tableAssert.assertTables(actual.getTables(), expected.getTables()); conditionAssert.assertOrCondition(actual.getRouteConditions().getOrCondition(), expected.getOrCondition()); - //conditionAssert.assertOrCondition(actual.getEncryptConditions().getOrCondition(), expected.getEncryptCondition()); + if(DatabaseType.MySQL == databaseType) { + conditionAssert.assertOrCondition(actual.getEncryptConditions().getOrCondition(), expected.getEncryptCondition()); + } tokenAssert.assertTokens(actual.getSQLTokens(), expected.getTokens()); indexAssert.assertParametersIndex(actual.getParametersIndex(), expected.getParameters().size()); if (actual instanceof SelectStatement) { diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/EncryptColumnTokenAssert.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/EncryptColumnTokenAssert.java index f208e3bea7296..5129f79a09e18 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/EncryptColumnTokenAssert.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/EncryptColumnTokenAssert.java @@ -31,14 +31,17 @@ import org.apache.shardingsphere.core.parse.integrate.jaxb.token.ExpectedTokens; import org.apache.shardingsphere.core.parse.parser.token.EncryptColumnToken; import org.apache.shardingsphere.core.parse.parser.token.SQLToken; +import org.apache.shardingsphere.test.sql.SQLCaseType; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public final class EncryptColumnTokenAssert { + private final SQLCaseType sqlCaseType; + private final SQLStatementAssertMessage assertMessage; - void assertIndexToken(final Collection actual, final ExpectedTokens expected) { + void assertEncryptColumnsToken(final Collection actual, final ExpectedTokens expected) { List encryptColumnTokens = getEncryptColumnTokens(actual); assertThat(assertMessage.getFullAssertMessage("Encrypt column tokens size error: "), encryptColumnTokens.size(), is(expected.getEncryptColumnTokens().size())); int count = 0; @@ -49,8 +52,13 @@ void assertIndexToken(final Collection actual, final ExpectedTokens ex } private void assertEncryptColumnToken(final EncryptColumnToken actual, final ExpectedEncryptColumnToken expected) { - assertThat(assertMessage.getFullAssertMessage("Encrypt column start index assertion error: "), actual.getStartIndex(), is(expected.getStartIndex())); - assertThat(assertMessage.getFullAssertMessage("Encrypt column stop index assertion error: "), actual.getStopIndex(), is(expected.getStopIndex())); + if(SQLCaseType.Placeholder == sqlCaseType){ + assertThat(assertMessage.getFullAssertMessage("Encrypt column start index for placeholder assertion error: "), actual.getStartIndex(), is(expected.getStartIndexForPlaceholder())); + assertThat(assertMessage.getFullAssertMessage("Encrypt column stop index for placeholder assertion error: "), actual.getStopIndex(), is(expected.getStopIndexForPlaceholder())); + }else { + assertThat(assertMessage.getFullAssertMessage("Encrypt column start index for literal assertion error: "), actual.getStartIndex(), is(expected.getStartIndexForLiteral())); + assertThat(assertMessage.getFullAssertMessage("Encrypt column stop index for literal assertion error: "), actual.getStopIndex(), is(expected.getStopIndexForLiteral())); + } assertNotNull(assertMessage.getFullAssertMessage("Encrypt column does not exist assertion error: "), expected.getColumn()); assertTrue(assertMessage.getFullAssertMessage("Missing encrypt column assertion error: "), actual.getColumn() != null); assertThat(assertMessage.getFullAssertMessage("Encrypt column name assertion error: "), actual.getColumn().getName(), is(expected.getColumn().getName())); diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/TokenAssert.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/TokenAssert.java index c9651596e8053..afd21e5ffaf31 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/TokenAssert.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/token/TokenAssert.java @@ -17,6 +17,7 @@ package org.apache.shardingsphere.core.parse.integrate.asserts.token; +import org.apache.shardingsphere.core.constant.DatabaseType; import org.apache.shardingsphere.core.parse.integrate.asserts.SQLStatementAssertMessage; import org.apache.shardingsphere.core.parse.integrate.jaxb.token.ExpectedTokens; import org.apache.shardingsphere.core.parse.parser.token.SQLToken; @@ -51,7 +52,11 @@ public final class TokenAssert { private final AggregationDistinctTokenAssert aggregationDistinctTokenAssert; - public TokenAssert(final SQLCaseType sqlCaseType, final SQLStatementAssertMessage assertMessage) { + private final EncryptColumnTokenAssert encryptColumnTokenAssert; + + private final DatabaseType databaseType; + + public TokenAssert(final SQLCaseType sqlCaseType, final SQLStatementAssertMessage assertMessage, final DatabaseType databaseType) { tableTokenAssert = new TableTokenAssert(assertMessage); schemaTokenAssert = new SchemaTokenAssert(assertMessage); indexTokenAssert = new IndexTokenAssert(assertMessage); @@ -62,6 +67,8 @@ public TokenAssert(final SQLCaseType sqlCaseType, final SQLStatementAssertMessag offsetTokenAssert = new OffsetTokenAssert(sqlCaseType, assertMessage); rowCountTokenAssert = new RowCountTokenAssert(sqlCaseType, assertMessage); aggregationDistinctTokenAssert = new AggregationDistinctTokenAssert(assertMessage); + encryptColumnTokenAssert = new EncryptColumnTokenAssert(sqlCaseType, assertMessage); + this.databaseType = databaseType; } /** @@ -81,5 +88,8 @@ public void assertTokens(final Collection actual, final ExpectedTokens offsetTokenAssert.assertOffsetToken(actual, expected); rowCountTokenAssert.assertRowCountToken(actual, expected); aggregationDistinctTokenAssert.assertAggregationDistinctTokens(actual, expected); + if(DatabaseType.MySQL == databaseType) { + encryptColumnTokenAssert.assertEncryptColumnsToken(actual, expected); + } } } diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/engine/IntegrateSupportedSQLParsingTest.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/engine/IntegrateSupportedSQLParsingTest.java index 28b25aaa44d2c..0d5bb4ddaae90 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/engine/IntegrateSupportedSQLParsingTest.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/engine/IntegrateSupportedSQLParsingTest.java @@ -63,6 +63,6 @@ public void assertSupportedSQL() { return; } new SQLStatementAssert(new SQLParsingEngine( - databaseType, sql, getShardingRule(), getShardingTableMetaData(), new ParsingResultCache()).parse(false), sqlCaseId, sqlCaseType).assertSQLStatement(); + databaseType, sql, getShardingRule(), getShardingTableMetaData(), new ParsingResultCache()).parse(false), sqlCaseId, sqlCaseType, databaseType).assertSQLStatement(); } } diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/jaxb/token/ExpectedEncryptColumnToken.java b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/jaxb/token/ExpectedEncryptColumnToken.java index 887ebad9ca842..41cdcf4836034 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/jaxb/token/ExpectedEncryptColumnToken.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/jaxb/token/ExpectedEncryptColumnToken.java @@ -29,11 +29,18 @@ @XmlAccessorType(XmlAccessType.FIELD) public final class ExpectedEncryptColumnToken { - @XmlAttribute(name = "start-index") - private int startIndex; + @XmlAttribute(name = "start-index-for-placeholder") + private int startIndexForPlaceholder; - @XmlAttribute(name = "stop-index") - private int stopIndex; + @XmlAttribute(name = "stop-index-for-placeholder") + private int stopIndexForPlaceholder; + + + @XmlAttribute(name = "start-index-for-literal") + private int startIndexForLiteral; + + @XmlAttribute(name = "stop-index-for-literal") + private int stopIndexForLiteral; private ExpectedColumn column; diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/delete.xml b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/delete.xml index 33d8c40edc5ae..28eb5dcc13c0c 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/delete.xml +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/delete.xml @@ -23,6 +23,9 @@ + + + @@ -34,6 +37,13 @@ + + + + + + + @@ -42,7 +52,17 @@ + + + + + + + + + + @@ -51,7 +71,17 @@ + + + + + + + + + + diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select.xml b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select.xml index c48810a4d735d..075c37a1f6fc2 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select.xml +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select.xml @@ -318,6 +318,9 @@ + + + @@ -334,6 +337,13 @@ + + + + + + + @@ -344,6 +354,9 @@ + + + @@ -360,6 +373,13 @@ + + + + + + + @@ -747,7 +767,17 @@ + + + + + + + + + + @@ -756,7 +786,17 @@ + + + + + + + + + + @@ -765,7 +805,17 @@ + + + + + + + + + + @@ -774,7 +824,17 @@ + + + + + + + + + + diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_or.xml b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_or.xml index 333dd21d22d9b..ed2640a05d373 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_or.xml +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_or.xml @@ -65,7 +65,17 @@ + + + + + + + + + + @@ -74,6 +84,9 @@ + + + @@ -90,6 +103,13 @@ + + + + + + + @@ -98,6 +118,9 @@ + + + @@ -133,6 +156,13 @@ + + + + + + + @@ -172,6 +202,9 @@ + + + @@ -191,5 +224,12 @@ + + + + + + + diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_order_by.xml b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_order_by.xml index 6a0a3de65c50b..dfaafa5e0702e 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_order_by.xml +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/select_order_by.xml @@ -43,11 +43,21 @@ o.order_id AS ORDER_BY_DERIVED_0 + + + + + + + + + + @@ -75,12 +85,22 @@ o.order_id AS ORDER_BY_DERIVED_0 + + + + + + + + + + diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/update.xml b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/update.xml index 473153d9904c6..cea6d59099ee7 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/update.xml +++ b/sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/resources/parser/update.xml @@ -23,6 +23,9 @@ + + + @@ -42,6 +45,9 @@ + + + @@ -80,6 +86,9 @@ + + + @@ -89,6 +98,9 @@ + + + @@ -108,6 +120,9 @@ + + + @@ -146,6 +161,9 @@ + + + @@ -165,6 +183,9 @@ + + + diff --git a/sharding-sql-test/src/main/resources/sql/dql/select.xml b/sharding-sql-test/src/main/resources/sql/dql/select.xml index dcd6b834556fe..4f9ff5008c9bb 100644 --- a/sharding-sql-test/src/main/resources/sql/dql/select.xml +++ b/sharding-sql-test/src/main/resources/sql/dql/select.xml @@ -58,8 +58,8 @@ - - + + From 0b3b65369bc0cb58912d2005cc267e6f5ce72179 Mon Sep 17 00:00:00 2001 From: codefairy08 Date: Thu, 4 Apr 2019 13:52:28 +0800 Subject: [PATCH 2/2] for checkstyle --- .../encrypt/segment/impl/EncryptOrConditionFiller.java | 6 +++--- .../filler/sharding/segment/impl/OrConditionFiller.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java index 4cf31df607398..14346ff3700c0 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/encrypt/segment/impl/EncryptOrConditionFiller.java @@ -79,16 +79,16 @@ private void fillColumnTableMap(final SQLStatement sqlStatement, final ShardingT private OrCondition filterCondition(final ShardingTableMetaData shardingTableMetaData, final SQLStatement sqlStatement, final OrConditionSegment orCondition, final String sql, final EncryptRule encryptRule, final Map columnNameToTable, final Map columnNameCount) { OrCondition result = new OrCondition(); - Set filledConditionStopIndexs = new HashSet(); + Set filledConditionStopIndexes = new HashSet<>(); for (AndConditionSegment each : orCondition.getAndConditions()) { for (ConditionSegment condition : each.getConditions()) { if (null == condition.getColumn()) { continue; } - if(filledConditionStopIndexs.contains(condition.getStopIndex())) { + if(filledConditionStopIndexes.contains(condition.getStopIndex())) { continue; }else { - filledConditionStopIndexs.add(condition.getStopIndex()); + filledConditionStopIndexes.add(condition.getStopIndex()); } Column column = new Column(condition.getColumn().getName(), getTableName(shardingTableMetaData, sqlStatement, condition)); fillEncryptCondition(column, condition, encryptRule, sqlStatement, sql); diff --git a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java index a9bb72b44653c..4ca0d00f819bb 100644 --- a/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java +++ b/sharding-core/sharding-core-parse/sharding-core-parse-common/src/main/java/org/apache/shardingsphere/core/parse/antlr/filler/sharding/segment/impl/OrConditionFiller.java @@ -127,7 +127,7 @@ private OrCondition filterCondition( break; } } - Set filledConditionStopIndexs = new HashSet(); + Set filledConditionStopIndexes = new HashSet<>(); for (AndConditionSegment each : orCondition.getAndConditions()) { for (ConditionSegment condition : each.getConditions()) { if (null == condition.getColumn()) { @@ -136,10 +136,10 @@ private OrCondition filterCondition( if (condition.getExpression() instanceof ColumnSegment) { continue; } - if(filledConditionStopIndexs.contains(condition.getStopIndex())) { + if(filledConditionStopIndexes.contains(condition.getStopIndex())) { continue; }else { - filledConditionStopIndexs.add(condition.getStopIndex()); + filledConditionStopIndexes.add(condition.getStopIndex()); } Column column = new Column(condition.getColumn().getName(), getTableName(shardingTableMetaData, shardingRule, sqlStatement, condition)); fillEncryptCondition(column, condition, shardingRule, sqlStatement, sql);