Search in sources :

Example 46 with ShardingRule

use of io.shardingjdbc.core.rule.ShardingRule 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();
}
Also used : ShardingRule(io.shardingjdbc.core.rule.ShardingRule) SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) Test(org.junit.Test)

Example 47 with ShardingRule

use of io.shardingjdbc.core.rule.ShardingRule 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);
}
Also used : ShardingRule(io.shardingjdbc.core.rule.ShardingRule) SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) InsertStatement(io.shardingjdbc.core.parsing.parser.sql.dml.insert.InsertStatement) Test(org.junit.Test)

Example 48 with ShardingRule

use of io.shardingjdbc.core.rule.ShardingRule 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();
}
Also used : ShardingRule(io.shardingjdbc.core.rule.ShardingRule) SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) Test(org.junit.Test)

Example 49 with ShardingRule

use of io.shardingjdbc.core.rule.ShardingRule 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();
}
Also used : ShardingRule(io.shardingjdbc.core.rule.ShardingRule) SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) Test(org.junit.Test)

Example 50 with ShardingRule

use of io.shardingjdbc.core.rule.ShardingRule in project sharding-jdbc by shardingjdbc.

the class InsertStatementParserTest method parseInsertFirstForOracle.

@Test(expected = SQLParsingUnsupportedException.class)
public void parseInsertFirstForOracle() {
    ShardingRule shardingRule = createShardingRule();
    new SQLParsingEngine(DatabaseType.Oracle, "INSERT FIRST INTO TABLE_XXX (field1) VALUES (field1) SELECT field1 FROM TABLE_XXX2", shardingRule).parse();
}
Also used : ShardingRule(io.shardingjdbc.core.rule.ShardingRule) SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) Test(org.junit.Test)

Aggregations

ShardingRule (io.shardingjdbc.core.rule.ShardingRule)60 Test (org.junit.Test)35 ShardingDataSource (io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource)20 SQLParsingEngine (io.shardingjdbc.core.parsing.SQLParsingEngine)19 ShardingRuleConfiguration (io.shardingjdbc.core.api.config.ShardingRuleConfiguration)16 TableRuleConfiguration (io.shardingjdbc.core.api.config.TableRuleConfiguration)14 DataSource (javax.sql.DataSource)14 BindingTableRule (io.shardingjdbc.core.rule.BindingTableRule)10 StandardShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration)8 DMLStatement (io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement)8 Map (java.util.Map)8 ComplexShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.ComplexShardingStrategyConfiguration)7 DatabaseType (io.shardingjdbc.core.constant.DatabaseType)7 TableRule (io.shardingjdbc.core.rule.TableRule)6 SQLShardingRule (io.shardingjdbc.core.integrate.jaxb.SQLShardingRule)5 InsertStatement (io.shardingjdbc.core.parsing.parser.sql.dml.insert.InsertStatement)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5 TestComplexKeysShardingAlgorithm (io.shardingjdbc.core.api.algorithm.fixture.TestComplexKeysShardingAlgorithm)4 InlineShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.InlineShardingStrategyConfiguration)4