@Test public void testSelectIsNotDdl() { sql("select 1 from t") .node(not(isDdl())); }
@Test public void testSelectIsNotDdl() { sql("select 1 from t") .node(not(isDdl())); }
@Test public void testInsertSelect() { final String expected = "INSERT INTO `EMPS`\n" + "(SELECT *\n" + "FROM `EMPS`)"; sql("insert into emps select * from emps") .ok(expected) .node(not(isDdl())); }
@Test public void testMergeSelectSource() { final String sql = "merge into emps e " + "using (select * from tempemps where deptno is null) t " + "on e.empno = t.empno " + "when matched then update " + "set name = t.name, deptno = t.deptno, salary = t.salary * .1 " + "when not matched then insert (name, dept, salary) " + "values(t.name, 10, t.salary * .15)"; final String expected = "MERGE INTO `EMPS` AS `E`\n" + "USING (SELECT *\n" + "FROM `TEMPEMPS`\n" + "WHERE (`DEPTNO` IS NULL)) AS `T`\n" + "ON (`E`.`EMPNO` = `T`.`EMPNO`)\n" + "WHEN MATCHED THEN UPDATE SET `NAME` = `T`.`NAME`\n" + ", `DEPTNO` = `T`.`DEPTNO`\n" + ", `SALARY` = (`T`.`SALARY` * 0.1)\n" + "WHEN NOT MATCHED THEN INSERT (`NAME`, `DEPT`, `SALARY`) " + "(VALUES (ROW(`T`.`NAME`, 10, (`T`.`SALARY` * 0.15))))"; sql(sql).ok(expected) .node(not(isDdl())); }
@Test public void testMergeSelectSource() { final String sql = "merge into emps e " + "using (select * from tempemps where deptno is null) t " + "on e.empno = t.empno " + "when matched then update " + "set name = t.name, deptno = t.deptno, salary = t.salary * .1 " + "when not matched then insert (name, dept, salary) " + "values(t.name, 10, t.salary * .15)"; final String expected = "MERGE INTO `EMPS` AS `E`\n" + "USING (SELECT *\n" + "FROM `TEMPEMPS`\n" + "WHERE (`DEPTNO` IS NULL)) AS `T`\n" + "ON (`E`.`EMPNO` = `T`.`EMPNO`)\n" + "WHEN MATCHED THEN UPDATE SET `NAME` = `T`.`NAME`\n" + ", `DEPTNO` = `T`.`DEPTNO`\n" + ", `SALARY` = (`T`.`SALARY` * 0.1)\n" + "WHEN NOT MATCHED THEN INSERT (`NAME`, `DEPT`, `SALARY`) " + "(VALUES (ROW(`T`.`NAME`, 10, (`T`.`SALARY` * 0.15))))"; sql(sql).ok(expected) .node(not(isDdl())); }
@Test public void testInsertValues() { final String expected = "INSERT INTO `EMPS`\n" + "VALUES (ROW(1, 'Fredkin'))"; sql("insert into emps values (1,'Fredkin')") .ok(expected) .node(not(isDdl())); }
@Test public void testExtendedSqlStmt() { sql("DESCRIBE SPACE POWER") .node(new IsNull<SqlNode>()); sql("DESCRIBE SEA ^POWER^") .fails("(?s)Encountered \"POWER\" at line 1, column 14..*"); } }
@Test public void testUpsertValues() { final String expected = "UPSERT INTO `EMPS`\n" + "VALUES (ROW(1, 'Fredkin'))"; final String sql = "upsert into emps values (1,'Fredkin')"; if (isReserved("UPSERT")) { sql(sql) .ok(expected) .node(not(isDdl())); } }
@Test public void testExplainInsert() { final String expected = "EXPLAIN PLAN INCLUDING ATTRIBUTES" + " WITH IMPLEMENTATION FOR\n" + "INSERT INTO `EMPS1`\n" + "(SELECT *\n" + "FROM `EMPS2`)"; sql("explain plan for insert into emps1 select * from emps2") .ok(expected) .node(not(isDdl())); }
@Test public void testInsertValuesRawDefault() { final String expected = "INSERT INTO `EMPS`\n" + "VALUES (ROW(DEFAULT))"; sql("insert into emps ^values^ default") .fails("(?s).*Encountered \"values default\" at .*"); sql("insert into emps values (default)") .ok(expected) .node(not(isDdl())); }
@Test public void testDelete() { sql("delete from emps") .ok("DELETE FROM `EMPS`") .node(not(isDdl())); }
@Test public void testInsertValuesDefault() { final String expected = "INSERT INTO `EMPS`\n" + "VALUES (ROW(1, DEFAULT, 'Fredkin'))"; sql("insert into emps values (1,DEFAULT,'Fredkin')") .ok(expected) .node(not(isDdl())); }
@Test public void testInsertValuesRawDefault() { final String expected = "INSERT INTO `EMPS`\n" + "VALUES (ROW(DEFAULT))"; sql("insert into emps ^values^ default") .fails("(?s).*Encountered \"values default\" at .*"); sql("insert into emps values (default)") .ok(expected) .node(not(isDdl())); }
@Test public void testInsertSelect() { final String expected = "INSERT INTO `EMPS`\n" + "(SELECT *\n" + "FROM `EMPS`)"; sql("insert into emps select * from emps") .ok(expected) .node(not(isDdl())); }
@Test public void testDelete() { sql("delete from emps") .ok("DELETE FROM `EMPS`") .node(not(isDdl())); }
@Test public void testInsertValuesDefault() { final String expected = "INSERT INTO `EMPS`\n" + "VALUES (ROW(1, DEFAULT, 'Fredkin'))"; sql("insert into emps values (1,DEFAULT,'Fredkin')") .ok(expected) .node(not(isDdl())); }
@Test public void testUpsertValues() { final String expected = "UPSERT INTO `EMPS`\n" + "VALUES (ROW(1, 'Fredkin'))"; sql("upsert into emps values (1,'Fredkin')") .ok(expected) .node(not(isDdl())); }
@Test public void testExplainInsert() { final String expected = "EXPLAIN PLAN INCLUDING ATTRIBUTES" + " WITH IMPLEMENTATION FOR\n" + "INSERT INTO `EMPS1`\n" + "(SELECT *\n" + "FROM `EMPS2`)"; sql("explain plan for insert into emps1 select * from emps2") .ok(expected) .node(not(isDdl())); }
@Test public void testInsertValues() { final String expected = "INSERT INTO `EMPS`\n" + "VALUES (ROW(1, 'Fredkin'))"; sql("insert into emps values (1,'Fredkin')") .ok(expected) .node(not(isDdl())); }
@Test public void testExtendedSqlStmt() { sql("DESCRIBE SPACE POWER") .node(new IsNull<SqlNode>()); sql("DESCRIBE SEA ^POWER^") .fails("(?s)Encountered \"POWER\" at line 1, column 14..*"); } }