X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FQ-Branch.git;a=blobdiff_plain;f=lib%2FSQL%2FAbstract%2FExtraClauses.pm;fp=lib%2FSQL%2FAbstract%2FExtraClauses.pm;h=e16f927b2a8e2e1ff4e94a23783a2520de00a7b6;hp=fe5af4efda4383bd6837ef5b6b68fbf2c03d8b3a;hb=6aac9987ce7af38ba7ff8271a59aa68cdc9b192e;hpb=8480fb63ab259ac41af9d6570eb313cb23c5eac8 diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index fe5af4e..e16f927 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -377,6 +377,11 @@ SQL::Abstract::ExtraClauses - new/experimental additions to L my $sqla = SQL::Abstract->new; SQL::Abstract::ExtraClauses->apply_to($sqla); +=head1 WARNING + +This module is basically a nursery for things that seem like a good idea +to live in until we figure out if we were right about that. + =head1 METHODS =head2 apply_to @@ -575,4 +580,44 @@ With oddities: x LEFT JOIN ( y LEFT JOIN z ) [] +=head1 STATEMENT EXTENSIONS + +=head2 group by clause for select + +Expanded as a list with an ident default: + + # expr + { -select => { group_by => [ 'foo', 'bar' ] } } + + # aqt + { -select => { group_by => + { + -op => [ ',', { -ident => [ 'foo' ] }, { -ident => [ 'bar' ] } ] + } + } } + + # query + GROUP BY foo, bar + [] + +=head2 having clause for select + +Basic expr, just like where, given having is pretty much post-group-by +where clause: + + # expr + { -select => + { having => { '>' => [ { -count => { -ident => 'foo' } }, 3 ] } } + } + + # aqt + { -select => { having => { -op => [ + '>', { -func => [ 'count', { -ident => [ 'foo' ] } ] }, + { -bind => [ undef, 3 ] }, + ] } } } + + # query + HAVING COUNT(foo) > ? + [ 3 ] + =cut