Search in sources :

Example 21 with SQLParsingEngine

use of io.shardingjdbc.core.parsing.SQLParsingEngine 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)

Example 22 with SQLParsingEngine

use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.

the class UpdateStatementParserTest method parseWithoutCondition.

@Test
public void parseWithoutCondition() {
    ShardingRule shardingRule = createShardingRule();
    SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "UPDATE TABLE_XXX SET field1=field1+1", shardingRule);
    DMLStatement updateStatement = (DMLStatement) statementParser.parse();
    assertThat(updateStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
}
Also used : ShardingRule(io.shardingjdbc.core.rule.ShardingRule) SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) DMLStatement(io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement) Test(org.junit.Test)

Example 23 with SQLParsingEngine

use of io.shardingjdbc.core.parsing.SQLParsingEngine in project sharding-jdbc by shardingjdbc.

the class IntegrateSupportedSQLParsingTest method assertSupportedSQL.

@Test
public void assertSupportedSQL() {
    String sql = sqlCasesLoader.getSupportedSQL(sqlCaseId, sqlCaseType, parserResultSetLoader.getParserResult(sqlCaseId).getParameters());
    new SQLStatementAssert(new SQLParsingEngine(databaseType, sql, getShardingRule()).parse(), sqlCaseId, sqlCaseType).assertSQLStatement();
}
Also used : SQLParsingEngine(io.shardingjdbc.core.parsing.SQLParsingEngine) SQLStatementAssert(io.shardingjdbc.core.parsing.integrate.asserts.SQLStatementAssert) Test(org.junit.Test)

Aggregations

SQLParsingEngine (io.shardingjdbc.core.parsing.SQLParsingEngine)23 ShardingRule (io.shardingjdbc.core.rule.ShardingRule)19 Test (org.junit.Test)17 DMLStatement (io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement)8 InsertStatement (io.shardingjdbc.core.parsing.parser.sql.dml.insert.InsertStatement)6 Column (io.shardingjdbc.core.parsing.parser.context.condition.Column)3 Condition (io.shardingjdbc.core.parsing.parser.context.condition.Condition)3 SQLStatement (io.shardingjdbc.core.parsing.parser.sql.SQLStatement)2 LinkedList (java.util.LinkedList)2 QueryResult (io.shardingjdbc.core.merger.QueryResult)1 MemoryQueryResultRow (io.shardingjdbc.core.merger.dql.common.MemoryQueryResultRow)1 SQLStatementAssert (io.shardingjdbc.core.parsing.integrate.asserts.SQLStatementAssert)1 TableRule (io.shardingjdbc.core.rule.TableRule)1 DatabaseProtocolPacket (io.shardingjdbc.proxy.transport.common.packet.DatabaseProtocolPacket)1 ColumnDefinition41Packet (io.shardingjdbc.proxy.transport.mysql.packet.command.text.query.ColumnDefinition41Packet)1 EofPacket (io.shardingjdbc.proxy.transport.mysql.packet.generic.EofPacket)1