From: Matt S Trout Date: Wed, 17 Apr 2019 01:08:52 +0000 (+0000) Subject: consolidate with_recursive X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FQ-Branch.git;a=commitdiff_plain;h=7237eb3cd700fd41a6ac61c823767f1797b3d9bd 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(', ',