use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.
the class DeleteStatementParserTest method parseWithSpecialSyntax.
private void parseWithSpecialSyntax(final DatabaseType dbType, final String actualSQL) {
ShardingRule shardingRule = createShardingRule();
DMLStatement deleteStatement = (DMLStatement) new SQLParsingEngine(dbType, actualSQL, shardingRule).parse();
assertThat(deleteStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
assertFalse(deleteStatement.getTables().find("TABLE_XXX").get().getAlias().isPresent());
Condition condition = deleteStatement.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));
}
use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.
the class DeleteStatementParserTest method parseStatementWithDeleteMultipleTableWithUsing.
@Test(expected = UnsupportedOperationException.class)
public void parseStatementWithDeleteMultipleTableWithUsing() {
ShardingRule shardingRule = createShardingRule();
new SQLParsingEngine(DatabaseType.MySQL, "DELETE FROM TABLE_XXX1, TABLE_xxx2 USING TABLE_XXX1 JOIN TABLE_XXX2", shardingRule).parse();
}
use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.
the class InsertStatementParserTest method assertParseWithGenerateKeyColumnsWithoutParameter.
@Test
public void assertParseWithGenerateKeyColumnsWithoutParameter() {
ShardingRule shardingRule = createShardingRuleWithGenerateKeyColumns();
SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "INSERT INTO `TABLE_XXX` (`field1`) VALUES (10)", shardingRule);
InsertStatement insertStatement = (InsertStatement) statementParser.parse();
assertInsertStatementWithoutParameter(insertStatement);
}
use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.
the class InsertStatementParserTest method parseInsertAllForOracle.
@Test(expected = SQLParsingUnsupportedException.class)
public void parseInsertAllForOracle() {
ShardingRule shardingRule = createShardingRule();
new SQLParsingEngine(DatabaseType.Oracle, "INSERT ALL INTO TABLE_XXX (field1) VALUES (field1) SELECT field1 FROM TABLE_XXX2", shardingRule).parse();
}
use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.
the class InsertStatementParserTest method parseMultipleInsertForMySQL.
@Test
public // TODO assert
void parseMultipleInsertForMySQL() {
ShardingRule shardingRule = createShardingRule();
new SQLParsingEngine(DatabaseType.MySQL, "INSERT INTO TABLE_XXX (`field1`, `field2`) VALUES (1, 'value_char'), (2, 'value_char')", shardingRule).parse();
}
Aggregations