@Test public void testIllegalCursors() { checkFails( "select ^cursor^(select * from emps) from emps", "CURSOR expression encountered in illegal context"); checkFails( "call list(^cursor^(select * from emps))", "CURSOR expression encountered in illegal context"); checkFails( "select f(^cursor^(select * from emps)) from emps", "CURSOR expression encountered in illegal context"); }
@Test public void testIllegalCursors() { checkFails( "select ^cursor^(select * from emps) from emps", "CURSOR expression encountered in illegal context"); checkFails( "call list(^cursor^(select * from emps))", "CURSOR expression encountered in illegal context"); checkFails( "select f(^cursor^(select * from emps)) from emps", "CURSOR expression encountered in illegal context"); }
/** * In modern SQL, a query can occur almost everywhere that an expression * can. This test tests the few exceptions. */ @Test public void testQueryInIllegalContext() { checkFails( "select 0, multiset[^(^select * from emp), 2] from dept", "Query expression encountered in illegal context"); checkFails( "select 0, multiset[1, ^(^select * from emp), 2, 3] from dept", "Query expression encountered in illegal context"); }
/** * In modern SQL, a query can occur almost everywhere that an expression * can. This test tests the few exceptions. */ @Test public void testQueryInIllegalContext() { checkFails( "select 0, multiset[^(^select * from emp), 2] from dept", "Query expression encountered in illegal context"); checkFails( "select 0, multiset[1, ^(^select * from emp), 2, 3] from dept", "Query expression encountered in illegal context"); }
@Test public void testCaseExpressionFails() { // Missing 'END' checkFails( "select case col1 when 1 then 'one' ^from^ t", "(?s).*from.*"); // Wrong 'WHEN' checkFails( "select case col1 ^when1^ then 'one' end from t", "(?s).*when1.*"); }
@Test public void testWithNestedFails() { // SQL standard does not allow WITH to contain WITH checkFails("with emp2 as (select * from emp)\n" + "^with^ dept2 as (select * from dept)\n" + "select 1 as uno from emp, dept", "(?s)Encountered \"with\" at .*"); }
@Test public void testSelectList4() { checkFails( "select ^from^ emp", "(?s).*Encountered \"from\" at line .*"); }
@Test public void testHavingBeforeGroupFails() { checkFails( "select deptno from emp having count(*) > 5 and deptno < 4 ^group^ by deptno, emp", "(?s).*Encountered \"group\" at .*"); }
@Test public void testHavingBeforeGroupFails() { checkFails( "select deptno from emp having count(*) > 5 and deptno < 4 ^group^ by deptno, emp", "(?s).*Encountered \"group\" at .*"); }
@Test public void testBitStringNotImplemented() { // Bit-string is longer part of the SQL standard. We do not support it. checkFails( "select B^'1011'^ || 'foobar' from (values (true))", "(?s).*Encountered \"\\\\'1011\\\\'\" at line 1, column 9.*"); }
@Test public void testWithNestedFails() { // SQL standard does not allow WITH to contain WITH checkFails("with emp2 as (select * from emp)\n" + "^with^ dept2 as (select * from dept)\n" + "select 1 as uno from emp, dept", "(?s)Encountered \"with\" at .*"); }
@Test public void testBitStringNotImplemented() { // Bit-string is longer part of the SQL standard. We do not support it. checkFails( "select B^'1011'^ || 'foobar' from (values (true))", "(?s).*Encountered \"\\\\'1011\\\\'\" at line 1, column 9.*"); }
@Test public void testUnionOfNonQueryFails() { checkFails( "select 1 from emp union ^2^ + 5", "Non-query expression encountered in illegal context"); }
@Test public void testWithFails() { checkFails("with femaleEmps as ^select^ * from emps where gender = 'F'\n" + "select deptno from femaleEmps", "(?s)Encountered \"select\" at .*"); }
@Test public void testFullInnerJoinFails() { // cannot have more than one of INNER, FULL, LEFT, RIGHT, CROSS checkFails( "select * from a ^full^ inner join b", "(?s).*Encountered \"full inner\" at line 1, column 17.*"); }
@Test public void testExplicitTable() { check("table emp", "(TABLE `EMP`)"); // FIXME should fail at "123" checkFails( "^table^ 123", "(?s)Encountered \"table 123\" at line 1, column 1\\.\n.*"); }
@Test public void testJoinUsing() { check( "select * from a join b using (x)", "SELECT *\n" + "FROM `A`\n" + "INNER JOIN `B` USING (`X`)"); checkFails( "select * from a join b using (^)^ where c = d", "(?s).*Encountered \"[)]\" at line 1, column 31.*"); }
@Test public void testOrderIllegalInExpression() { check( "select (select 1 from foo order by x,y) from t where a = b", "SELECT (SELECT 1\n" + "FROM `FOO`\n" + "ORDER BY `X`, `Y`)\n" + "FROM `T`\n" + "WHERE (`A` = `B`)"); checkFails( "select (1 ^order^ by x, y) from t where a = b", "ORDER BY unexpected"); }
@Test public void testOrderIllegalInExpression() { check( "select (select 1 from foo order by x,y) from t where a = b", "SELECT (SELECT 1\n" + "FROM `FOO`\n" + "ORDER BY `X`, `Y`)\n" + "FROM `T`\n" + "WHERE (`A` = `B`)"); checkFails( "select (1 ^order^ by x, y) from t where a = b", "ORDER BY unexpected"); }
@Test public void testExplicitTable() { check("table emp", "(TABLE `EMP`)"); // FIXME should fail at "123" checkFails( "^table^ 123", "(?s)Encountered \"table 123\" at line 1, column 1\\.\n.*"); }