use of io.shardingjdbc.core.rule.ShardingRule in project sharding-jdbc by shardingjdbc.
the class DeleteStatementParserTest method parseWithoutCondition.
@Test
public void parseWithoutCondition() {
ShardingRule shardingRule = createShardingRule();
SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "DELETE FROM TABLE_XXX", shardingRule);
DMLStatement deleteStatement = (DMLStatement) statementParser.parse();
assertThat(deleteStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
}
use of io.shardingjdbc.core.rule.ShardingRule in project sharding-jdbc by shardingjdbc.
the class DeleteStatementParserTest method parseStatementWithDeleteMultipleTable.
@Test(expected = UnsupportedOperationException.class)
public void parseStatementWithDeleteMultipleTable() {
ShardingRule shardingRule = createShardingRule();
new SQLParsingEngine(DatabaseType.MySQL, "DELETE TABLE_XXX1, TABLE_xxx2 FROM TABLE_XXX1 JOIN TABLE_XXX2", shardingRule).parse();
}
use of io.shardingjdbc.core.rule.ShardingRule in project sharding-jdbc by shardingjdbc.
the class DeleteStatementParserTest method parseWithParameter.
@Test
public void parseWithParameter() {
ShardingRule shardingRule = createShardingRule();
SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "DELETE FROM TABLE_XXX xxx WHERE field4<? AND field1=? AND field5>? AND field2 IN (?,?) AND field6<=? AND field3 BETWEEN ? AND ? AND field7>=?", shardingRule);
DMLStatement deleteStatement = (DMLStatement) statementParser.parse();
assertDeleteStatementWithParameter(deleteStatement);
}
use of io.shardingjdbc.core.rule.ShardingRule in project sharding-jdbc by shardingjdbc.
the class DeleteStatementParserTest method parseWithoutParameter.
@Test
public void parseWithoutParameter() {
ShardingRule shardingRule = createShardingRule();
SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "DELETE FROM TABLE_XXX xxx WHERE field4<10 AND TABLE_XXX.field1=1 AND field5>10 AND xxx.field2 IN (1,3) AND field6<=10 AND field3 BETWEEN 5 AND 20 AND field7>=10", shardingRule);
DMLStatement deleteStatement = (DMLStatement) statementParser.parse();
assertDeleteStatementWithoutParameter(deleteStatement);
}
use of io.shardingjdbc.core.rule.ShardingRule in project sharding-jdbc by shardingjdbc.
the class InsertStatementParserTest method parseWithSpecialSyntax.
@SuppressWarnings("unchecked")
private void parseWithSpecialSyntax(final DatabaseType dbType, final String actualSQL) {
ShardingRule shardingRule = createShardingRule();
InsertStatement insertStatement = (InsertStatement) new SQLParsingEngine(dbType, actualSQL, shardingRule).parse();
assertThat(insertStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
assertFalse(insertStatement.getTables().find("TABLE_XXX").get().getAlias().isPresent());
Condition condition = insertStatement.getConditions().find(new Column("field1", "TABLE_XXX")).get();
assertThat(condition.getOperator(), is(ShardingOperator.EQUAL));
assertThat(((ListShardingValue<? extends Comparable>) condition.getShardingValue(Collections.emptyList())).getValues().iterator().next(), is((Comparable) 1));
}
Aggregations