From: Matt S Trout Date: Thu, 11 Apr 2019 17:49:31 +0000 (+0000) Subject: add group_by and having in ExtraClauses X-Git-Tag: v1.90_01~231 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ff9018cf680b289394dbf93c0ec533bfaead7a7;p=dbsrgits%2FSQL-Abstract.git add group_by and having in ExtraClauses --- diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm new file mode 100644 index 0000000..9e5ddff --- /dev/null +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -0,0 +1,26 @@ +package SQL::Abstract::ExtraClauses; + +use strict; +use warnings; +use if $] < '5.010', 'MRO::Compat'; +use mro 'c3'; +use base qw(SQL::Abstract::Clauses); + +BEGIN { *puke = \&SQL::Abstract::puke } + +sub new { + my ($proto, @args) = @_; + my $new = $proto->next::method(@args); + $new->{clauses_of}{select} = [ + @{$new->{clauses_of}{select}}, qw(group_by having) + ]; + $new->{expand_clause}{'select.group_by'} = sub { + $_[0]->_expand_maybe_list_expr($_[1], -ident) + }; + $new->{expand_clause}{'select.having'} = sub { + $_[0]->expand_expr($_[1], -ident) + }; + return $new; +} + +1;