Skip to content
New issue

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

Reconstruct the parsing for sqlTokens #2311

Merged
merged 77 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
5210fc0
delete GeneratedKeyToken.java
tristaZero Apr 30, 2019
2b45d1a
do not assert GeneratedKeyToken
tristaZero Apr 30, 2019
9f6a198
do not use InsertColumnToken
tristaZero Apr 30, 2019
508a01c
delete InsertColumnToken
tristaZero Apr 30, 2019
385fa60
add stopIndex
tristaZero Apr 30, 2019
9331812
rename beginPosition to startIndex
tristaZero Apr 30, 2019
4f4f320
add stopIndex
tristaZero Apr 30, 2019
3117b3d
modify initializing OffsetToken
tristaZero Apr 30, 2019
700f4db
modify cases for OffsetToken
tristaZero Apr 30, 2019
2d8d07b
use OffsetToken
tristaZero Apr 30, 2019
0951e88
modify initializing OffsetToken
tristaZero Apr 30, 2019
0130bf2
add stopIndex
tristaZero Apr 30, 2019
dcf5f70
modify initializing OrderByToken
tristaZero Apr 30, 2019
2d62134
modify cases for OrderByToken
tristaZero Apr 30, 2019
662b1d4
add stopIndex
tristaZero Apr 30, 2019
5c18e72
add stopIndex
tristaZero Apr 30, 2019
d282e42
add stopIndexOfOwner
tristaZero Apr 30, 2019
23fc2ec
modify initialzing tableToken
tristaZero Apr 30, 2019
08169bd
add stopIndexOfOwner and ownerQuoteCharacter
tristaZero Apr 30, 2019
a1eb238
modify initializing tableToken
tristaZero Apr 30, 2019
b084b2c
modify test cases for tableToken
tristaZero Apr 30, 2019
c815902
modify test cases for tableToken
tristaZero Apr 30, 2019
e506739
modify initializing table token
tristaZero Apr 30, 2019
5a6fe18
modify test cases for tableToken
tristaZero Apr 30, 2019
33c9290
use tableToken
tristaZero Apr 30, 2019
bf10963
add stopIndex for father class
tristaZero Apr 30, 2019
5530f70
delete stopIndex for AggregationDistinctToken
tristaZero Apr 30, 2019
e387ddd
delete stopIndex
tristaZero Apr 30, 2019
7968d7b
move stopIndex to parent class
tristaZero Apr 30, 2019
c3dea31
add author
tristaZero Apr 30, 2019
9e16d2d
modify initializing RowCountToken
tristaZero Apr 30, 2019
3cd9fdf
add stopIndex
tristaZero Apr 30, 2019
a8df667
modify test cases for rowCountToken
tristaZero Apr 30, 2019
7e63063
add valueEndPosition
tristaZero Apr 30, 2019
a8841c4
add valueEndPosition
tristaZero Apr 30, 2019
1bb21f9
new RowCountToken
tristaZero Apr 30, 2019
902a977
modify appendTablePlaceholder()
tristaZero Apr 30, 2019
305a825
modify cases for tableToken
tristaZero Apr 30, 2019
bd2b871
modify appendItemsToken()
tristaZero Apr 30, 2019
78b6311
modify appendInsertValuesToken()
tristaZero Apr 30, 2019
c71deb4
fill InsertValuesToken
tristaZero Apr 30, 2019
687f60b
add stopIndex
tristaZero Apr 30, 2019
29d285d
create InsertValuesToken
tristaZero Apr 30, 2019
2534639
modify cases for insert value token
tristaZero Apr 30, 2019
8ce8a67
modify initializing InsertValuesToken
tristaZero Apr 30, 2019
7f57584
add stopIndex
tristaZero Apr 30, 2019
dd4cea1
fill InsertSetToken
tristaZero Apr 30, 2019
897641a
modify cases for InsertSetToken
tristaZero Apr 30, 2019
c6567b6
parse InsertSetToken
tristaZero Apr 30, 2019
54e189c
modify appendLimitRowCount()
tristaZero Apr 30, 2019
a32a595
modify cases for appendLimitRowCount
tristaZero Apr 30, 2019
46fdc73
modify appendLimitOffsetToken()
tristaZero Apr 30, 2019
a79c00e
modify appendRest()
tristaZero Apr 30, 2019
9528720
modify appendTokensAndPlaceholders()
tristaZero Apr 30, 2019
9a51738
calculate stopIndex
tristaZero Apr 30, 2019
f28ee7c
use itemstoken
tristaZero Apr 30, 2019
1d24056
delete getLength()
tristaZero Apr 30, 2019
bf6980f
do not assert actual.getLength()
tristaZero Apr 30, 2019
8ba31d5
delete ownerLength
tristaZero Apr 30, 2019
9d94951
use RemoveToken
tristaZero Apr 30, 2019
b6ac89d
calculate RemoveToken stop index
tristaZero Apr 30, 2019
c3e4642
use appendRest() for removeToken
tristaZero Apr 30, 2019
1d4e972
delete ownerLength
tristaZero Apr 30, 2019
6709d00
delete skippedSchemaNameLength
tristaZero Apr 30, 2019
e6e166d
fill TableToken
tristaZero Apr 30, 2019
3d4e0fb
modify tests for table token
tristaZero Apr 30, 2019
b1760bf
modify cases for table token
tristaZero Apr 30, 2019
76c344c
new TableToke
tristaZero Apr 30, 2019
86493c3
fill table token
tristaZero Apr 30, 2019
43a5ad0
add sql
tristaZero May 1, 2019
c77151e
add sql parameter for newInstance()
tristaZero May 1, 2019
2723fe0
use getStart().getStopIndex()
tristaZero May 1, 2019
345bb14
add sql parameter for SQLServerInsertParser
tristaZero May 1, 2019
a7cae22
use sql parameter for insert statement
tristaZero May 1, 2019
2997aa4
Merge branch 'dev' of ssh://github.com/shardingjdbc/sharding-jdbc int…
tristaZero May 1, 2019
8423d9f
each.getStopIndex() + 1
tristaZero May 1, 2019
89cc034
Merge branch 'dev' of ssh://github.com/shardingjdbc/sharding-jdbc int…
tristaZero May 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public void assertInsertStatementWithValuesWithPlaceHolderWithEncrypt() {
private InsertStatement createInsertStatementWithValuesWithPlaceHolderWithEncrypt() {
InsertStatement result = new InsertStatement();
result.getTables().add(new Table("t_encrypt", null));
result.addSQLToken(new TableToken(12, "t_encrypt", QuoteCharacter.NONE, 0));
result.addSQLToken(new InsertValuesToken(34));
result.addSQLToken(new TableToken(12, 20, "t_encrypt", QuoteCharacter.NONE));
result.addSQLToken(new InsertValuesToken(21, 46));
result.getColumnNames().add("col1");
result.getColumnNames().add("col2");
result.getValues().add(new InsertValue(Arrays.<SQLExpression>asList(new SQLParameterMarkerExpression(0), new SQLParameterMarkerExpression(1))));
Expand All @@ -112,8 +112,8 @@ public void assertInsertStatementWithValuesWithoutPlaceHolderWithQueryEncrypt()
private InsertStatement createInsertStatementWithValuesWithoutPlaceHolderWithQueryEncrypt() {
InsertStatement result = new InsertStatement();
result.getTables().add(new Table("t_query_encrypt", null));
result.addSQLToken(new TableToken(12, "t_query_encrypt", QuoteCharacter.NONE, 0));
result.addSQLToken(new InsertValuesToken(40));
result.addSQLToken(new TableToken(12, 27, "t_query_encrypt", QuoteCharacter.NONE));
result.addSQLToken(new InsertValuesToken(27, 52));
result.getColumnNames().add("col1");
result.getColumnNames().add("col2");
result.getValues().add(new InsertValue(Arrays.<SQLExpression>asList(new SQLNumberExpression(1), new SQLNumberExpression(2))));
Expand All @@ -138,8 +138,8 @@ public void assertInsertStatementWithSetWithoutPlaceHolderWithEncrypt() {
private InsertStatement createInsertStatementWithSetWithoutPlaceHolderWithEncrypt() {
InsertStatement result = new InsertStatement();
result.getTables().add(new Table("t_encrypt", null));
result.addSQLToken(new TableToken(12, "t_encrypt", QuoteCharacter.NONE, 0));
result.addSQLToken(new InsertSetToken(34));
result.addSQLToken(new TableToken(12, 20, "t_encrypt", QuoteCharacter.NONE));
result.addSQLToken(new InsertSetToken(12, 20));
result.getColumnNames().add("col1");
result.getColumnNames().add("col2");
result.getValues().add(new InsertValue(Arrays.<SQLExpression>asList(new SQLNumberExpression(1), new SQLNumberExpression(2))));
Expand All @@ -166,8 +166,8 @@ public void assertInsertStatementWithSetWithPlaceHolderWithQueryEncrypt() {
private InsertStatement createInsertStatementWithSetWithPlaceHolderWithQueryEncrypt() {
InsertStatement result = new InsertStatement();
result.getTables().add(new Table("t_query_encrypt", null));
result.addSQLToken(new TableToken(12, "t_query_encrypt", QuoteCharacter.NONE, 0));
result.addSQLToken(new InsertSetToken(40));
result.addSQLToken(new TableToken(12, 26, "t_query_encrypt", QuoteCharacter.NONE));
result.addSQLToken(new InsertSetToken(12, 27));
result.getColumnNames().add("col1");
result.getColumnNames().add("col2");
result.getValues().add(new InsertValue(Arrays.<SQLExpression>asList(new SQLParameterMarkerExpression(0), new SQLParameterMarkerExpression(1))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private void initializeInsertValuesWithPlaceHolder() {
insertValuesStatementWithPlaceHolder = new InsertStatement();
insertValuesStatementWithPlaceHolder.getTables().add(new Table("t_order", null));
insertValuesStatementWithPlaceHolder.setParametersIndex(4);
insertValuesStatementWithPlaceHolder.addSQLToken(new TableToken(12, "t_order", QuoteCharacter.NONE, 0));
insertValuesStatementWithPlaceHolder.addSQLToken(new InsertValuesToken(39));
insertValuesStatementWithPlaceHolder.addSQLToken(new TableToken(12, 18, "t_order", QuoteCharacter.NONE));
insertValuesStatementWithPlaceHolder.addSQLToken(new InsertValuesToken(21, 46));
AndCondition andCondition1 = new AndCondition();
andCondition1.getConditions().add(new Condition(new Column("user_id", "t_order"), new SQLParameterMarkerExpression(0)));
insertValuesStatementWithPlaceHolder.getRouteConditions().getOrCondition().getAndConditions().add(andCondition1);
Expand All @@ -137,8 +137,8 @@ private void initializeInsertValuesWithPlaceHolderWithEncrypt() {
insertValuesStatementWithPlaceHolderWithEncrypt = new InsertStatement();
insertValuesStatementWithPlaceHolderWithEncrypt.getTables().add(new Table("t_encrypt", null));
insertValuesStatementWithPlaceHolderWithEncrypt.setParametersIndex(4);
insertValuesStatementWithPlaceHolderWithEncrypt.addSQLToken(new TableToken(12, "t_encrypt", QuoteCharacter.NONE, 0));
insertValuesStatementWithPlaceHolderWithEncrypt.addSQLToken(new InsertValuesToken(39));
insertValuesStatementWithPlaceHolderWithEncrypt.addSQLToken(new TableToken(12, 20, "t_encrypt", QuoteCharacter.NONE));
insertValuesStatementWithPlaceHolderWithEncrypt.addSQLToken(new InsertValuesToken(21, 46));
AndCondition andCondition1 = new AndCondition();
andCondition1.getConditions().add(new Condition(new Column("user_id", "t_encrypt"), new SQLParameterMarkerExpression(0)));
insertValuesStatementWithPlaceHolderWithEncrypt.getRouteConditions().getOrCondition().getAndConditions().add(andCondition1);
Expand All @@ -156,8 +156,8 @@ private void initializeInsertValuesWithoutPlaceHolder() {
insertValuesStatementWithoutPlaceHolder = new InsertStatement();
insertValuesStatementWithoutPlaceHolder.getTables().add(new Table("t_order", null));
insertValuesStatementWithoutPlaceHolder.setParametersIndex(0);
insertValuesStatementWithoutPlaceHolder.addSQLToken(new TableToken(12, "t_order", QuoteCharacter.NONE, 0));
insertValuesStatementWithoutPlaceHolder.addSQLToken(new InsertValuesToken(42));
insertValuesStatementWithoutPlaceHolder.addSQLToken(new TableToken(12, 20, "t_order", QuoteCharacter.NONE));
insertValuesStatementWithoutPlaceHolder.addSQLToken(new InsertValuesToken(27, 52));
ItemsToken itemsToken = new ItemsToken(34);
itemsToken.getItems().add("order_id");
insertValuesStatementWithoutPlaceHolder.addSQLToken(itemsToken);
Expand All @@ -170,8 +170,8 @@ private void initializeInsertValuesWithoutPlaceHolderWithQueryEncrypt() {
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt = new InsertStatement();
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.getTables().add(new Table("t_encrypt_query", null));
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.setParametersIndex(0);
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.addSQLToken(new TableToken(12, "t_encrypt_query", QuoteCharacter.NONE, 0));
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.addSQLToken(new InsertValuesToken(42));
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.addSQLToken(new TableToken(12, 26, "t_encrypt_query", QuoteCharacter.NONE));
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.addSQLToken(new InsertValuesToken(27, 52));
ItemsToken itemsToken = new ItemsToken(34);
itemsToken.getItems().add("order_id");
insertValuesStatementWithoutPlaceHolderWithQueryEncrypt.addSQLToken(itemsToken);
Expand All @@ -184,8 +184,8 @@ private void initializeInsertSetWithPlaceHolder() {
insertSetStatementWithPlaceHolder = new InsertStatement();
insertSetStatementWithPlaceHolder.getTables().add(new Table("t_order", null));
insertSetStatementWithPlaceHolder.setParametersIndex(0);
insertSetStatementWithPlaceHolder.addSQLToken(new TableToken(12, "t_order", QuoteCharacter.NONE, 0));
insertSetStatementWithPlaceHolder.addSQLToken(new InsertSetToken(24));
insertSetStatementWithPlaceHolder.addSQLToken(new TableToken(12, 18, "t_order", QuoteCharacter.NONE));
insertSetStatementWithPlaceHolder.addSQLToken(new InsertSetToken(12, 20));
insertSetStatementWithPlaceHolder.getColumnNames().add("user_id");
insertSetStatementWithPlaceHolder.getColumnNames().add("status");
AndCondition andCondition = new AndCondition();
Expand All @@ -197,8 +197,8 @@ private void initializeInsertSetWithPlaceHolderWithQueryEncrypt() {
insertSetStatementWithPlaceHolderWithQueryEncrypt = new InsertStatement();
insertSetStatementWithPlaceHolderWithQueryEncrypt.getTables().add(new Table("t_encrypt_query", null));
insertSetStatementWithPlaceHolderWithQueryEncrypt.setParametersIndex(0);
insertSetStatementWithPlaceHolderWithQueryEncrypt.addSQLToken(new TableToken(12, "t_encrypt_query", QuoteCharacter.NONE, 0));
insertSetStatementWithPlaceHolderWithQueryEncrypt.addSQLToken(new InsertSetToken(24));
insertSetStatementWithPlaceHolderWithQueryEncrypt.addSQLToken(new TableToken(12, 26, "t_encrypt_query", QuoteCharacter.NONE));
insertSetStatementWithPlaceHolderWithQueryEncrypt.addSQLToken(new InsertSetToken(12, 20));
insertSetStatementWithPlaceHolderWithQueryEncrypt.getColumnNames().add("user_id");
insertSetStatementWithPlaceHolderWithQueryEncrypt.getColumnNames().add("status");
AndCondition andCondition = new AndCondition();
Expand All @@ -210,8 +210,8 @@ private void initializeInsertSetWithoutPlaceHolder() {
insertSetStatementWithoutPlaceHolder = new InsertStatement();
insertSetStatementWithoutPlaceHolder.getTables().add(new Table("t_order", null));
insertSetStatementWithoutPlaceHolder.setParametersIndex(0);
insertSetStatementWithoutPlaceHolder.addSQLToken(new TableToken(12, "t_order", QuoteCharacter.NONE, 0));
insertSetStatementWithoutPlaceHolder.addSQLToken(new InsertSetToken(24));
insertSetStatementWithoutPlaceHolder.addSQLToken(new TableToken(12, 18, "t_order", QuoteCharacter.NONE));
insertSetStatementWithoutPlaceHolder.addSQLToken(new InsertSetToken(12, 20));
insertSetStatementWithoutPlaceHolder.getColumnNames().add("user_id");
insertSetStatementWithoutPlaceHolder.getColumnNames().add("status");
AndCondition andCondition = new AndCondition();
Expand All @@ -223,8 +223,8 @@ private void initializeInsertSetWithoutPlaceHolderWithEncrypt() {
insertSetStatementWithoutPlaceHolderWithEncrypt = new InsertStatement();
insertSetStatementWithoutPlaceHolderWithEncrypt.getTables().add(new Table("t_encrypt", null));
insertSetStatementWithoutPlaceHolderWithEncrypt.setParametersIndex(0);
insertSetStatementWithoutPlaceHolderWithEncrypt.addSQLToken(new TableToken(12, "t_encrypt", QuoteCharacter.NONE, 0));
insertSetStatementWithoutPlaceHolderWithEncrypt.addSQLToken(new InsertSetToken(24));
insertSetStatementWithoutPlaceHolderWithEncrypt.addSQLToken(new TableToken(12, 20, "t_encrypt", QuoteCharacter.NONE));
insertSetStatementWithoutPlaceHolderWithEncrypt.addSQLToken(new InsertSetToken(12, 20));
insertSetStatementWithoutPlaceHolderWithEncrypt.getColumnNames().add("user_id");
insertSetStatementWithoutPlaceHolderWithEncrypt.getColumnNames().add("status");
AndCondition andCondition = new AndCondition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Optional<TableSegment> extract(final ParserRuleContext ancestorNode, fina
tableName = nodeText;
owner = Optional.absent();
}
TableSegment result = new TableSegment(tableNameNode.get().getStart().getStartIndex(), tableName);
TableSegment result = new TableSegment(tableNameNode.get().getStart().getStartIndex(), tableNameNode.get().getStart().getStopIndex(), tableName);
if (owner.isPresent()) {
result.setOwner(owner.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Limit extractor.
*
* @author duhongjun
* @author panjuan
*/
public final class LimitExtractor implements OptionalSQLSegmentExtractor {

Expand All @@ -53,8 +54,12 @@ public Optional<LimitSegment> extract(final ParserRuleContext ancestorNode, fina
}

private LimitValueSegment createLimitValueSegment(final Map<ParserRuleContext, Integer> placeholderAndNodeIndexMap, final ParserRuleContext limitValueNode) {
return Symbol.QUESTION.getLiterals().equals(limitValueNode.getText())
? new PlaceholderLimitValueSegment(placeholderAndNodeIndexMap.get(limitValueNode.getChild(0)), ((ParserRuleContext) limitValueNode.getChild(0)).getStart().getStartIndex())
: new LiteralLimitValueSegment(NumberUtil.getExactlyNumber(limitValueNode.getText(), 10).intValue(), limitValueNode.getStart().getStartIndex());
if (Symbol.QUESTION.getLiterals().equals(limitValueNode.getText())) {
ParserRuleContext placeholderLimitValueNode = (ParserRuleContext) limitValueNode.getChild(0);
return new PlaceholderLimitValueSegment(placeholderAndNodeIndexMap.get(placeholderLimitValueNode),
placeholderLimitValueNode.getStart().getStartIndex(), placeholderLimitValueNode.getStart().getStopIndex());

}
return new LiteralLimitValueSegment(NumberUtil.getExactlyNumber(limitValueNode.getText(), 10).intValue(), limitValueNode.getStart().getStartIndex(), limitValueNode.getStart().getStopIndex());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void fill(final InsertColumnsSegment sqlSegment, final SQLStatement sqlSt
} else {
fillFromSQL(sqlSegment, insertStatement);
}
insertStatement.getSQLTokens().add(new InsertValuesToken(sqlSegment.getStartIndex()));
insertStatement.getSQLTokens().add(new InsertValuesToken(sqlSegment.getStartIndex(), sqlStatement.getLogicSQL().length() - 1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void setOffset(final LimitValueSegment offsetSegment, final SelectStatem
if (offsetSegment instanceof LiteralLimitValueSegment) {
int value = ((LiteralLimitValueSegment) offsetSegment).getValue();
selectStatement.getLimit().setOffset(new LimitValue(value, -1, false));
selectStatement.getSQLTokens().add(new OffsetToken(offsetSegment.getStartIndex(), value));
selectStatement.getSQLTokens().add(new OffsetToken(offsetSegment.getStartIndex(), offsetSegment.getStopIndex(), value));
} else {
selectStatement.getLimit().setOffset(new LimitValue(-1, ((PlaceholderLimitValueSegment) offsetSegment).getParameterIndex(), false));
}
Expand All @@ -60,7 +60,7 @@ private void setRowCount(final LimitValueSegment rowCountSegment, final SelectSt
if (rowCountSegment instanceof LiteralLimitValueSegment) {
int value = ((LiteralLimitValueSegment) rowCountSegment).getValue();
selectStatement.getLimit().setRowCount(new LimitValue(value, -1, false));
selectStatement.getSQLTokens().add(new RowCountToken(rowCountSegment.getStartIndex(), value));
selectStatement.getSQLTokens().add(new RowCountToken(rowCountSegment.getStartIndex(), rowCountSegment.getStopIndex(), value));
} else {
selectStatement.getLimit().setRowCount(new LimitValue(-1, ((PlaceholderLimitValueSegment) rowCountSegment).getParameterIndex(), false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.base.Optional;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.core.metadata.table.ShardingTableMetaData;
import org.apache.shardingsphere.core.parse.antlr.constant.QuoteCharacter;
import org.apache.shardingsphere.core.parse.antlr.filler.api.SQLSegmentFiller;
import org.apache.shardingsphere.core.parse.antlr.sql.segment.SQLSegment;
import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.expr.complex.SubquerySegment;
Expand Down Expand Up @@ -86,7 +85,7 @@ private void fillShorthandSelectItemSegment(final ShorthandSelectItemSegment sel
Optional<Table> table = selectStatement.getTables().find(owner.get());
if (table.isPresent() && !table.get().getAlias().isPresent() && shardingTableMetaData.containsTable(table.get().getName())) {
// FIXME for QuoteCharacter.getQuoteCharacter(owner), if order by `xxx`.xx, has problem
selectStatement.addSQLToken(new TableToken(selectItemSegment.getStartIndex(), owner.get(), QuoteCharacter.getQuoteCharacter(owner.get()), 0));
selectStatement.addSQLToken(new TableToken(selectItemSegment.getStartIndex(), selectItemSegment.getStopIndexOfOwner(), owner.get(), selectItemSegment.getOwnerQuoteCharacter()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void fillInsert(final SetAssignmentsSegment sqlSegment, final InsertStat
InsertValue insertValue = getInsertValue(sqlSegment, insertStatement.getLogicSQL());
insertStatement.getValues().add(insertValue);
insertStatement.setParametersIndex(insertValue.getParametersCount());
insertStatement.getSQLTokens().add(new InsertSetToken(sqlSegment.getStartIndex()));
insertStatement.getSQLTokens().add(new InsertSetToken(sqlSegment.getStartIndex(), insertStatement.getLogicSQL().length() - 1));
}

private InsertValue getInsertValue(final SetAssignmentsSegment sqlSegment, final String sql) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*
* @author duhongjun
* @author zhangliang
* @author panjuan
*/
@Setter
public final class ShardingColumnFiller implements SQLSegmentFiller<ColumnSegment>, ShardingTableMetaDataAwareFiller {
Expand All @@ -45,7 +46,7 @@ public void fill(final ColumnSegment sqlSegment, final SQLStatement sqlStatement
}
Optional<Table> logicTable = sqlStatement.getTables().find(sqlSegment.getOwner().get());
if (logicTable.isPresent() && !logicTable.get().getAlias().isPresent() && shardingTableMetaData.containsTable(logicTable.get().getName())) {
sqlStatement.addSQLToken(new TableToken(sqlSegment.getStartIndex(), logicTable.get().getName(), sqlSegment.getOwnerQuoteCharacter(), 0));
sqlStatement.addSQLToken(new TableToken(sqlSegment.getStartIndex(), sqlSegment.getStopIndexOfOwner(), logicTable.get().getName(), sqlSegment.getOwnerQuoteCharacter()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @author duhongjun
* @author zhangliang
* @author panjuan
*/
@Setter
public final class ShardingTableFiller implements SQLSegmentFiller<TableSegment>, ShardingRuleAwareFiller {
Expand All @@ -44,7 +45,7 @@ public final class ShardingTableFiller implements SQLSegmentFiller<TableSegment>
public void fill(final TableSegment sqlSegment, final SQLStatement sqlStatement) {
if (isTableInShardingRule(sqlSegment.getName()) || !(sqlStatement instanceof SelectStatement)) {
sqlStatement.getTables().add(new Table(sqlSegment.getName(), sqlSegment.getAlias().orNull()));
sqlStatement.getSQLTokens().add(new TableToken(sqlSegment.getStartIndex(), sqlSegment.getName(), sqlSegment.getQuoteCharacter(), sqlSegment.getOwnerLength()));
sqlStatement.getSQLTokens().add(new TableToken(sqlSegment.getStartIndex(), sqlSegment.getStopIndex(), sqlSegment.getName(), sqlSegment.getQuoteCharacter()));
}
if (sqlStatement instanceof DMLStatement && !sqlStatement.getTables().isSingleTable()) {
throw new SQLParsingUnsupportedException("Cannot support Multiple-Table.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void fillInsert(final SetAssignmentsSegment sqlSegment, final InsertStat
insertStatement.getValues().add(insertValue);
insertStatement.getRouteConditions().getOrCondition().getAndConditions().add(andCondition);
insertStatement.setParametersIndex(insertValue.getParametersCount());
insertStatement.getSQLTokens().add(new InsertSetToken(sqlSegment.getStartIndex()));
insertStatement.getSQLTokens().add(new InsertSetToken(sqlSegment.getStartIndex(), insertStatement.getLogicSQL().length() - 1));
}

private int getColumnCountExcludeAssistedQueryColumns(final InsertStatement insertStatement) {
Expand Down
Loading