Skip to content

Commit

Permalink
parser: syntax: add tests for count() syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
PauloMigAlmeida committed Sep 17, 2023
1 parent 0a785f4 commit a1b4993
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tests/parser/syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,20 @@ static void test_select_stmt(void)

// big boss
CU_ASSERT_EQUAL(try_parse_stmt("SELECT "
" a.name, COUNT(a.name), c.name as country_name "
" FROM "
" PEOPLE a INNER JOIN COUNTRIES c "
" ON a.country_id = c.id "
" WHERE"
" a LIKE 'Paulo%' "
" GROUP BY "
" a.name "
" HAVING "
" COUNT(a.name) > 10 "
" ORDER BY "
" country_name DESC,"
" a.name ASC ;"), 0);
" a.name, COUNT(a.name), c.name as country_name "
" FROM "
" PEOPLE a INNER JOIN COUNTRIES c "
" ON a.country_id = c.id "
" WHERE"
" a LIKE 'Paulo%' "
" GROUP BY "
" a.name "
" HAVING "
" COUNT(a.name) > 10 "
" ORDER BY "
" country_name DESC,"
" a.name ASC ;"),
0);

/*
* invalid tests
Expand Down Expand Up @@ -361,6 +362,11 @@ static void test_select_stmt(void)
// join with no ON-clause -> MySQL had this crazy idea
CU_ASSERT_NOT_EQUAL(try_parse_stmt("SELECT A.f1, B.f2 FROM A JOIN B WHERE A.f1 = B.f2;"), 0);

// select count with multiple fields (FIELDNAME RPN)
CU_ASSERT_NOT_EQUAL(try_parse_stmt("SELECT COUNT(A.f1, B.f2) FROM A, B;"), 0);

// select count with multiple fields (NAME RPN)
CU_ASSERT_NOT_EQUAL(try_parse_stmt("SELECT COUNT(f1, f2) FROM A;"), 0);
}

void test_syntax_parse(void)
Expand Down

0 comments on commit a1b4993

Please sign in to comment.