use of io.shardingjdbc.core.rule.BindingTableRule in project sharding-jdbc by shardingjdbc.
the class SQLRewriteEngine method getTableTokens.
private Map<String, String> getTableTokens(final CartesianTableReference cartesianTableReference) {
Map<String, String> result = new HashMap<>();
for (TableUnit each : cartesianTableReference.getTableUnits()) {
String logicTableName = each.getLogicTableName().toLowerCase();
result.put(logicTableName, each.getActualTableName());
Optional<BindingTableRule> bindingTableRule = shardingRule.findBindingTableRule(logicTableName);
if (bindingTableRule.isPresent()) {
result.putAll(getBindingTableTokens(each, bindingTableRule.get()));
}
}
return result;
}
use of io.shardingjdbc.core.rule.BindingTableRule in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingNamespaceTest method assertMultiBindingTableRulesDatasource.
@Test
public void assertMultiBindingTableRulesDatasource() {
ShardingRule shardingRule = getShardingRule("multiBindingTableRulesDatasource");
assertThat(shardingRule.getBindingTableRules().size(), is(2));
Iterator<BindingTableRule> bindingTableRules = shardingRule.getBindingTableRules().iterator();
BindingTableRule orderRule = bindingTableRules.next();
assertThat(orderRule.getBindingActualTable("dbtbl_0", "t_order", "t_order_item"), is("t_order"));
assertThat(orderRule.getBindingActualTable("dbtbl_1", "t_order", "t_order_item"), is("t_order"));
BindingTableRule userRule = bindingTableRules.next();
assertThat(userRule.getBindingActualTable("dbtbl_0", "t_user", "t_user_detail"), is("t_user"));
assertThat(userRule.getBindingActualTable("dbtbl_1", "t_user", "t_user_detail"), is("t_user"));
}
use of io.shardingjdbc.core.rule.BindingTableRule in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingNamespaceTest method assertBindingTableRuleDatasource.
@Test
public void assertBindingTableRuleDatasource() {
ShardingRule shardingRule = getShardingRule("bindingTableRuleDatasource");
assertThat(shardingRule.getBindingTableRules().size(), is(1));
BindingTableRule bindingTableRule = shardingRule.getBindingTableRules().iterator().next();
assertThat(bindingTableRule.getBindingActualTable("dbtbl_0", "t_order", "t_order_item"), is("t_order"));
assertThat(bindingTableRule.getBindingActualTable("dbtbl_1", "t_order", "t_order_item"), is("t_order"));
}
use of io.shardingjdbc.core.rule.BindingTableRule in project sharding-jdbc by shardingjdbc.
the class ShardingNamespaceTest method assertMultiBindingTableRulesDatasource.
@Test
public void assertMultiBindingTableRulesDatasource() {
ShardingRule shardingRule = getShardingRule("multiBindingTableRulesDatasource");
assertThat(shardingRule.getBindingTableRules().size(), is(2));
Iterator<BindingTableRule> bindingTableRules = shardingRule.getBindingTableRules().iterator();
BindingTableRule orderRule = bindingTableRules.next();
assertThat(orderRule.getBindingActualTable("dbtbl_0", "t_order", "t_order_item"), is("t_order"));
assertThat(orderRule.getBindingActualTable("dbtbl_1", "t_order", "t_order_item"), is("t_order"));
BindingTableRule userRule = bindingTableRules.next();
assertThat(userRule.getBindingActualTable("dbtbl_0", "t_user", "t_user_detail"), is("t_user"));
assertThat(userRule.getBindingActualTable("dbtbl_1", "t_user", "t_user_detail"), is("t_user"));
}
use of io.shardingjdbc.core.rule.BindingTableRule in project sharding-jdbc by shardingjdbc.
the class ShardingNamespaceTest method assertBindingTableRuleDatasource.
@Test
public void assertBindingTableRuleDatasource() {
ShardingRule shardingRule = getShardingRule("bindingTableRuleDatasource");
assertThat(shardingRule.getBindingTableRules().size(), is(1));
BindingTableRule bindingTableRule = shardingRule.getBindingTableRules().iterator().next();
assertThat(bindingTableRule.getBindingActualTable("dbtbl_0", "t_order", "t_order_item"), is("t_order"));
assertThat(bindingTableRule.getBindingActualTable("dbtbl_1", "t_order", "t_order_item"), is("t_order"));
}
Aggregations