Skip to content

Commit

Permalink
fix #382
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Sep 19, 2017
1 parent 187d46d commit 440b331
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ public boolean isAllBindingTables(final Collection<String> logicTables) {
return !bindingTables.isEmpty() && bindingTables.containsAll(logicTables);
}

/**
* Adjust logic tables is all belong to default data source.
*
* @param logicTables names of logic tables
* @return logic tables is all belong to default data source
*/
public boolean isAllInDefaultDataSource(final Collection<String> logicTables) {
for (String each : logicTables) {
if (tryFindTableRule(each).isPresent()) {
return false;
}
}
return true;
}

/**
* Filter all binding tables.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public SQLRouteResult route(final String logicSQL, final List<Object> parameters
private RoutingResult route(final List<Object> parameters, final SQLStatement sqlStatement) {
Collection<String> tableNames = sqlStatement.getTables().getTableNames();
RoutingEngine routingEngine;
if (1 == tableNames.size() || shardingRule.isAllBindingTables(tableNames)) {
if (1 == tableNames.size() || shardingRule.isAllBindingTables(tableNames) || shardingRule.isAllInDefaultDataSource(tableNames)) {
routingEngine = new SimpleRoutingEngine(shardingRule, parameters, tableNames.iterator().next(), sqlStatement);
} else {
// TODO config for cartesian set
Expand Down

0 comments on commit 440b331

Please sign in to comment.