use of io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement in project sharding-jdbc by shardingjdbc.
the class UpdateStatementParserTest method parseWithSpecialSyntax.
private void parseWithSpecialSyntax(final DatabaseType dbType, final String actualSQL) {
ShardingRule shardingRule = createShardingRule();
DMLStatement updateStatement = (DMLStatement) new SQLParsingEngine(dbType, actualSQL, shardingRule).parse();
assertThat(updateStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
assertFalse(updateStatement.getTables().find("TABLE_XXX").get().getAlias().isPresent());
Condition condition = updateStatement.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((Object) 1));
}
use of io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement 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.parsing.parser.sql.dml.DMLStatement 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.parsing.parser.sql.dml.DMLStatement 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.parsing.parser.sql.dml.DMLStatement in project sharding-jdbc by shardingjdbc.
the class UpdateStatementParserTest method parseWithoutParameter.
@Test
public void parseWithoutParameter() {
ShardingRule shardingRule = createShardingRule();
SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "UPDATE TABLE_XXX xxx SET TABLE_XXX.field1=field1+1,xxx.field2=2 WHERE TABLE_XXX.field4<10 AND" + " TABLE_XXX.field1=1 AND xxx.field5>10 AND TABLE_XXX.field2 IN (1,3) AND xxx.field6<=10 AND TABLE_XXX.field3 BETWEEN 5 AND 20 AND xxx.field7>=10", shardingRule);
DMLStatement updateStatement = (DMLStatement) statementParser.parse();
assertUpdateStatementWithoutParameter(updateStatement);
}
Aggregations