| 39 | ASSERT_EQ(node.GetValue()->Dump(), val); |
| 40 | |
| 41 | TEST(SQLParserTest, Simple) { |
| 42 | AssertSyntaxError(Parse("x")); |
| 43 | AssertSyntaxError(Parse("1")); |
| 44 | AssertSyntaxError(Parse("select")); |
| 45 | AssertSyntaxError(Parse("where")); |
| 46 | AssertSyntaxError(Parse("limit")); |
| 47 | AssertSyntaxError(Parse("from a")); |
| 48 | AssertSyntaxError(Parse("select 0 from")); |
| 49 | AssertSyntaxError(Parse("select 0 from b")); |
| 50 | AssertSyntaxError(Parse("select a from 123")); |
| 51 | AssertSyntaxError(Parse("select a from \"b\"")); |
| 52 | AssertSyntaxError(Parse("select a from b, c")); |
| 53 | AssertSyntaxError(Parse("select a from b where")); |
| 54 | AssertSyntaxError(Parse("select a from b hello")); |
| 55 | AssertSyntaxError(Parse("select a from b where")); |
| 56 | AssertSyntaxError(Parse("select a from b where 1")); |
| 57 | AssertSyntaxError(Parse("select a from b where 0")); |
| 58 | AssertSyntaxError(Parse("select a from b where \"x\"")); |
| 59 | AssertSyntaxError(Parse("select a from b where limit 10")); |
| 60 | AssertSyntaxError(Parse("select a from b where true and")); |
| 61 | AssertSyntaxError(Parse("select a from b where (true")); |
| 62 | AssertSyntaxError(Parse("select a from b where (true))")); |
| 63 | AssertSyntaxError(Parse("select a from b where 1 >")); |
| 64 | AssertSyntaxError(Parse("select a from b where x =")); |
| 65 | AssertSyntaxError(Parse("select a from b where x hastag")); |
| 66 | AssertSyntaxError(Parse("select a from b where =")); |
| 67 | AssertSyntaxError(Parse("select a from b where hastag x")); |
| 68 | AssertSyntaxError(Parse("select a from b where = 1")); |
| 69 | AssertSyntaxError(Parse("select a from b where x hashtag \"")); |
| 70 | AssertSyntaxError(Parse(R"(select a from b where x hashtag "\p")")); |
| 71 | AssertSyntaxError(Parse(R"(select a from b where x hashtag "\u11")")); |
| 72 | AssertSyntaxError(Parse(R"(select a from b where x hashtag "\")")); |
| 73 | AssertSyntaxError(Parse(R"(select a from b where x hashtag "abc)")); |
| 74 | AssertSyntaxError(Parse("select a from b where limit 10")); |
| 75 | AssertSyntaxError(Parse("select a from b limit 1, 1, 1")); |
| 76 | AssertSyntaxError(Parse("select a from b limit -10")); |
| 77 | AssertSyntaxError(Parse("select a from b limit")); |
| 78 | AssertSyntaxError(Parse("select a from b order")); |
| 79 | AssertSyntaxError(Parse("select a from b order by")); |
| 80 | AssertSyntaxError(Parse("select a from b order by a bsc")); |
| 81 | AssertSyntaxError(Parse("select a from b order a")); |
| 82 | AssertSyntaxError(Parse("select a from b order asc")); |
| 83 | AssertSyntaxError(Parse("select a from b order by a limit")); |
| 84 | |
| 85 | AssertIR(Parse("select a from b"), "select a from b where true"); |
| 86 | AssertIR(Parse(" select a from b "), "select a from b where true"); |
| 87 | AssertIR(Parse("\nselect\n a\t \tfrom \n\nb "), "select a from b where true"); |
| 88 | AssertIR(Parse("select * from b"), "select * from b where true"); |
| 89 | AssertIR(Parse("select a, b from c"), "select a, b from c where true"); |
| 90 | AssertIR(Parse("select a, b, c from d"), "select a, b, c from d where true"); |
| 91 | AssertIR(Parse("select xY_z12_3 , X00 from b"), "select xY_z12_3, X00 from b where true"); |
| 92 | AssertIR(Parse("select a from b where true"), "select a from b where true"); |
| 93 | AssertIR(Parse("select a from b where false"), "select a from b where false"); |
| 94 | AssertIR(Parse("select a from b where true and true"), "select a from b where (and true, true)"); |
| 95 | AssertIR(Parse("select a from b where false and true and false"), "select a from b where (and false, true, false)"); |
| 96 | AssertIR(Parse("select a from b where false or true"), "select a from b where (or false, true)"); |
| 97 | AssertIR(Parse("select a from b where true or false or true"), "select a from b where (or true, false, true)"); |
| 98 | AssertIR(Parse("select a from b where false and true or false"), |