From 38f0e3469e03f409c5c32a3cffa1c01d9134c8b7 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 24 Oct 2018 12:25:07 +0100 Subject: [PATCH] Add GROUP BY ALL to SQL SELECT queries --- sql/select.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sql/select.go b/sql/select.go index 3ea03cb3..9ebd5e3f 100644 --- a/sql/select.go +++ b/sql/select.go @@ -158,6 +158,24 @@ func (p *parser) parseGroup() (mul Groups, err error) { _, _, _ = p.mightBe(BY) + // If the next token is the ALL keyword then + // we will group all records together, which + // will prevent grouping by other fields. + + if _, _, exi := p.mightBe(ALL); exi { + + mul = append(mul, &Group{ + Expr: new(All), + }) + + return + + } + + // Otherwise let's parse the fields with which + // we will group the selected data, with + // multiple fields grouped by commas. + for { var tok Token