add group_by and having in ExtraClauses
[scpubgit/Q-Branch.git] / lib / SQL / Abstract / ExtraClauses.pm
1 package SQL::Abstract::ExtraClauses;
2
3 use strict;
4 use warnings;
5 use if $] < '5.010', 'MRO::Compat';
6 use mro 'c3';
7 use base qw(SQL::Abstract::Clauses);
8
9 BEGIN { *puke = \&SQL::Abstract::puke }
10
11 sub new {
12   my ($proto, @args) = @_;
13   my $new = $proto->next::method(@args);
14   $new->{clauses_of}{select} = [
15     @{$new->{clauses_of}{select}}, qw(group_by having)
16   ];
17   $new->{expand_clause}{'select.group_by'} = sub {
18     $_[0]->_expand_maybe_list_expr($_[1], -ident)
19   };
20   $new->{expand_clause}{'select.having'} = sub {
21     $_[0]->expand_expr($_[1], -ident)
22   };
23   return $new;
24 }
25
26 1;