fix group_by
This commit is contained in:
parent
4e0cdec7f7
commit
86d51a3d6c
2 changed files with 25 additions and 1 deletions
|
@ -129,6 +129,24 @@ group by
|
|||
select name from items group by 1, 2;
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(select_statement
|
||||
(select_item
|
||||
(identifier))
|
||||
(select_from
|
||||
(from_item
|
||||
(from_table
|
||||
(identifier))))
|
||||
(select_group_by
|
||||
(number)
|
||||
(number))))
|
||||
|
||||
================================================================================
|
||||
group by with parens
|
||||
================================================================================
|
||||
select name from items group by (1, 2);
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(select_statement
|
||||
(select_item
|
||||
|
|
|
@ -511,7 +511,13 @@ module.exports = grammar({
|
|||
kw("offset"), $._value_expression,
|
||||
optional(choice(kw("row"), kw("rows")))
|
||||
),
|
||||
select_group_by: $ => seq(kw("group"), kw("by"), commaSep1($._value_expression)),
|
||||
// TODO(chrde): rollup, cube, grouping sets
|
||||
select_group_by: $ => prec(1, seq(kw("group"), kw("by"),
|
||||
choice(
|
||||
seq("(", commaSep1($._value_expression), ")"),
|
||||
commaSep1($._value_expression),
|
||||
),
|
||||
)),
|
||||
select_order_by: $ => seq(kw("order"), kw("by"), commaSep1($.order_by_item)),
|
||||
order_by_item: $ => seq($._value_expression, optional($.order_by_direction)),
|
||||
order_by_direction: $ => choice(kw("asc"), kw("desc")),
|
||||
|
|
Loading…
Reference in a new issue