use of io.shardingjdbc.core.parsing.parser.token.ItemsToken in project sharding-jdbc by shardingjdbc.
the class InsertStatement method appendGenerateKeyToken.
/**
* Append generate key token.
*
* @param shardingRule databases and tables sharding rule
*/
public void appendGenerateKeyToken(final ShardingRule shardingRule) {
if (null != generatedKey) {
return;
}
Optional<TableRule> tableRule = shardingRule.tryFindTableRuleByLogicTable(getTables().getSingleTableName());
if (!tableRule.isPresent()) {
return;
}
Optional<GeneratedKeyToken> generatedKeysToken = findGeneratedKeyToken();
if (!generatedKeysToken.isPresent()) {
return;
}
ItemsToken valuesToken = new ItemsToken(generatedKeysToken.get().getBeginPosition());
appendGenerateKeyToken(shardingRule, tableRule.get(), valuesToken);
getSqlTokens().remove(generatedKeysToken.get());
getSqlTokens().add(valuesToken);
}
use of io.shardingjdbc.core.parsing.parser.token.ItemsToken in project sharding-jdbc by shardingjdbc.
the class AbstractSelectParser method appendDerivedColumns.
private void appendDerivedColumns(final SelectStatement selectStatement) {
ItemsToken itemsToken = new ItemsToken(selectStatement.getSelectListLastPosition());
appendAvgDerivedColumns(itemsToken, selectStatement);
appendDerivedOrderColumns(itemsToken, selectStatement.getOrderByItems(), ORDER_BY_DERIVED_ALIAS, selectStatement);
appendDerivedOrderColumns(itemsToken, selectStatement.getGroupByItems(), GROUP_BY_DERIVED_ALIAS, selectStatement);
if (!itemsToken.getItems().isEmpty()) {
selectStatement.getSqlTokens().add(itemsToken);
}
}
Aggregations