From: Matt S Trout Date: Wed, 17 Apr 2019 01:08:52 +0000 (+0000) Subject: consolidate with_recursive X-Git-Tag: v2.000000~3^2~218 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=631135cd9907436f1674f1cc206ab6d1aed66992;p=dbsrgits%2FSQL-Abstract.git consolidate with_recursive --- diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index 1fb0e2c..6a27d43 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -117,7 +117,8 @@ sub register_defaults { ); $self->clause_expander('select.with' => my $with_expander = sub { - my ($self, undef, $with) = @_; + my ($self, $name, $with) = @_; + my (undef, $type) = split '_', $name; if (ref($with) eq 'HASH') { return +{ %$with, @@ -134,16 +135,9 @@ sub register_defaults { $self->expand_expr($query) ]; } - return +{ queries => \@exp }; - }); - $self->clause_expander('select.with_recursive' => sub { - my ($self, undef, $with) = @_; - my $exp = $self->$with_expander(undef, $with); - return +(with => +{ - %$exp, - type => 'recursive' - }); + return +(with => { ($type ? (type => $type) : ()), queries => \@exp }); }); + $self->clause_expander('select.with_recursive', $with_expander); $self->clause_renderer('select.with' => sub { my ($self, undef, $with) = @_; my $q_part = [ $self->join_clauses(', ',