parseWithSpecialSyntax(JdbcConstants.MYSQL,"DELETE `TABLE_XXX` WHERE `field1`=1");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"DELETE LOW_PRIORITY QUICK IGNORE TABLE_XXX PARTITION (partition_1) WHERE field1=1 ORDER BY field1 LIMIT 10");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"DELETE FROM TABLE_XXX PARTITION (partition_1, partition_2,partition_3) WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"DELETE /*+ index(field1) */ ONLY (TABLE_XXX) WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"DELETE /*+ index(field1) */ ONLY (TABLE_XXX) WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.SQL_SERVER,"DELETE TOP(10) OUTPUT (inserted.field1) FROM TABLE_XXX WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,"DELETE FROM ONLY TABLE_XXX USING producers WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,"DELETE FROM ONLY TABLE_XXX USING producers WHERE field1=1 OUTPUT *");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"DELETE `TABLE_XXX` WHERE `field1`=1","DELETE [Token(TABLE_XXX)] WHERE `field1`=1");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"DELETE LOW_PRIORITY QUICK IGNORE TABLE_XXX PARTITION (partition_1) WHERE field1=1 ORDER BY field1 LIMIT 10",
"DELETE LOW_PRIORITY QUICK IGNORE [Token(TABLE_XXX)] PARTITION (partition_1) WHERE field1=1 ORDER BY field1 LIMIT 10");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"DELETE FROM TABLE_XXX PARTITION (partition_1, partition_2,partition_3) WHERE field1=1",
"DELETE FROM [Token(TABLE_XXX)] PARTITION (partition_1, partition_2,partition_3) WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"DELETE /*+ index(field1) */ ONLY (TABLE_XXX) WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG",
"DELETE /*+ index(field1) */ ONLY ([Token(TABLE_XXX)]) WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"DELETE /*+ index(field1) */ ONLY (TABLE_XXX) WHERE field1=1 RETURNING *",
"DELETE /*+ index(field1) */ ONLY ([Token(TABLE_XXX)]) WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.SQL_SERVER,
"WITH field_query (field1, field2) AS (SELECT field1, field2 FROM TABLE_XXX AS xxx GROUP BY field1) DELETE TOP(10) OUTPUT (inserted.field1) FROM TABLE_XXX WHERE field1=1",
"WITH field_query (field1, field2) AS (SELECT field1, field2 FROM TABLE_XXX AS xxx GROUP BY field1) DELETE TOP(10) OUTPUT (inserted.field1) FROM [Token(TABLE_XXX)] WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,
"WITH RECURSIVE field_query (field1) AS (SELECT field1 FROM TABLE_XXX AS xxx ORDER BY field1 DESC) DELETE FROM ONLY TABLE_XXX USING producers WHERE field1=1 RETURNING *",
"WITH RECURSIVE field_query (field1) AS (SELECT field1 FROM TABLE_XXX AS xxx ORDER BY field1 DESC) DELETE FROM ONLY [Token(TABLE_XXX)] USING producers WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,
"WITH field1_query AS (SELECT field1 FROM TABLE_XXX), field2_query AS (SELECT field2 FROM TABLE_XXX) DELETE FROM ONLY TABLE_XXX USING producers WHERE field1=1 OUTPUT *",
"WITH field1_query AS (SELECT field1 FROM TABLE_XXX), field2_query AS (SELECT field2 FROM TABLE_XXX) DELETE FROM ONLY [Token(TABLE_XXX)] USING producers WHERE field1=1 OUTPUT *");
@@ -105,16 +105,26 @@ public final class InsertStatementParserTest extends AbstractStatementParserTest
@Test
publicvoidparseWithSpecialSyntax(){
parseWithSpecialSyntax(JdbcConstants.MYSQL,"INSERT LOW_PRIORITY IGNORE INTO `TABLE_XXX` PARTITION (partition1,partition2) (`field1`) VALUE (1)");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"INSERT INTO TABLE_XXX SET field1=1");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"INSERT LOW_PRIORITY IGNORE INTO `TABLE_XXX` PARTITION (partition1,partition2) (`field1`) VALUE (1)",
"INSERT LOW_PRIORITY IGNORE INTO [Token(TABLE_XXX)] PARTITION (partition1,partition2) (`field1`) VALUE (1)");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"INSERT INTO TABLE_XXX SET field1=1","INSERT INTO [Token(TABLE_XXX)] SET field1=1");
// TODO
// parseWithSpecialSyntax(JdbcConstants.MYSQL, "INSERT INTO TABLE_XXX (field1) SELECT field1 FROM TABLE_XXX2 ON DUPLICATE KEY UPDATE field1=field1+1");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"INSERT /*+ index(field1) */ INTO TABLE_XXX (`field1`) VALUES (1) RETURNING field1*2 LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.SQL_SERVER,"INSERT TOP(10) INTO OUTPUT TABLE_XXX (`field1`) VALUES (1)");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,"INSERT INTO TABLE_XXX (field1) VALUES (1) RETURNING id");
// parseWithSpecialSyntax(JdbcConstants.MYSQL, "INSERT INTO TABLE_XXX (field1) SELECT field1 FROM TABLE_XXX2 ON DUPLICATE KEY UPDATE field1=field1+1",
// "INSERT INTO [Token(TABLE_XXX)] (field1) SELECT field1 FROM TABLE_XXX2 ON DUPLICATE KEY UPDATE field1=field1+1");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"INSERT /*+ index(field1) */ INTO TABLE_XXX (`field1`) VALUES (1) RETURNING field1*2 LOG ERRORS INTO TABLE_LOG",
"INSERT /*+ index(field1) */ INTO [Token(TABLE_XXX)] (`field1`) VALUES (1) RETURNING field1*2 LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.SQL_SERVER,
"WITH field_query (field1, field2) AS (SELECT field1, field2 FROM TABLE_XXX AS xxx GROUP BY field1) INSERT TOP(10) INTO OUTPUT TABLE_XXX (`field1`) VALUES (1)",
"WITH field_query (field1, field2) AS (SELECT field1, field2 FROM TABLE_XXX AS xxx GROUP BY field1) INSERT TOP(10) INTO OUTPUT [Token(TABLE_XXX)] (`field1`) VALUES (1)");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,
"WITH RECURSIVE field_query (field1, field2) AS (SELECT field1, field2 FROM TABLE_XXX AS xxx ORDER BY field1 DESC) INSERT INTO TABLE_XXX (field1) VALUES (1) RETURNING id",
"WITH RECURSIVE field_query (field1, field2) AS (SELECT field1, field2 FROM TABLE_XXX AS xxx ORDER BY field1 DESC) INSERT INTO [Token(TABLE_XXX)] (field1) VALUES (1) RETURNING id");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,
"WITH field1_query AS (SELECT field1 FROM TABLE_XXX), field2_query AS (SELECT field2 FROM TABLE_XXX) INSERT INTO TABLE_XXX (field1) VALUES (1) RETURNING *",
"WITH field1_query AS (SELECT field1 FROM TABLE_XXX), field2_query AS (SELECT field2 FROM TABLE_XXX) INSERT INTO [Token(TABLE_XXX)] (field1) VALUES (1) RETURNING *");
@@ -81,17 +81,27 @@ public final class UpdateStatementParserTest extends AbstractStatementParserTest
@Test
publicvoidparseWithSpecialSyntax(){
parseWithSpecialSyntax(JdbcConstants.MYSQL,"UPDATE `TABLE_XXX` SET `field1`=1 WHERE `field1`=1");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"UPDATE LOW_PRIORITY IGNORE TABLE_XXX SET field1=1 WHERE field1=1 ORDER BY field1 LIMIT 10");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.SQL_SERVER,"UPDATE TOP(10) TABLE_XXX SET field1=1 OUTPUT (inserted.field1) WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,"UPDATE ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,"UPDATE ONLY TABLE_XXX SET (field1,field2)=(1,?) WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"UPDATE `TABLE_XXX` SET `field1`=1 WHERE `field1`=1","UPDATE [Token(TABLE_XXX)] SET `field1`=1 WHERE `field1`=1");
parseWithSpecialSyntax(JdbcConstants.MYSQL,"UPDATE LOW_PRIORITY IGNORE TABLE_XXX SET field1=1 WHERE field1=1 ORDER BY field1 LIMIT 10",
"UPDATE LOW_PRIORITY IGNORE [Token(TABLE_XXX)] SET field1=1 WHERE field1=1 ORDER BY field1 LIMIT 10");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG",
"UPDATE /*+ index(field1) */ ONLY [Token(TABLE_XXX)] SET field1=1 WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURNING *",
"UPDATE /*+ index(field1) */ ONLY [Token(TABLE_XXX)] SET field1=1 WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.ORACLE,"UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 LOG ERRORS INTO TABLE_LOG",
"UPDATE /*+ index(field1) */ ONLY [Token(TABLE_XXX)] SET field1=1 WHERE field1=1 LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(JdbcConstants.SQL_SERVER,
"WITH field_query (field1) AS (SELECT field1 FROM TABLE_XXX AS xxx GROUP BY field1) UPDATE TOP(10) TABLE_XXX SET field1=1 OUTPUT (inserted.field1) WHERE field1=1",
"WITH field_query (field1) AS (SELECT field1 FROM TABLE_XXX AS xxx GROUP BY field1) UPDATE TOP(10) [Token(TABLE_XXX)] SET field1=1 OUTPUT (inserted.field1) WHERE field1=1");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,
"WITH RECURSIVE field_query (field1) AS (SELECT field1 FROM TABLE_XXX AS xxx ORDER BY field1 DESC) UPDATE ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURNING *",
"WITH RECURSIVE field_query (field1) AS (SELECT field1 FROM TABLE_XXX AS xxx ORDER BY field1 DESC) UPDATE ONLY [Token(TABLE_XXX)] SET field1=1 WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(JdbcConstants.POSTGRESQL,
"WITH field1_query AS (SELECT field1 FROM TABLE_XXX), field2_query AS (SELECT field2 FROM TABLE_XXX) UPDATE ONLY TABLE_XXX SET (field1,field2)=(1,?) WHERE field1=1",
"WITH field1_query AS (SELECT field1 FROM TABLE_XXX), field2_query AS (SELECT field2 FROM TABLE_XXX) UPDATE ONLY [Token(TABLE_XXX)] SET (field1,field2)=(1,?) WHERE field1=1");