From: Matt S Trout Date: Mon, 23 Sep 2019 01:42:38 +0000 (+0000) Subject: extract setop expansion X-Git-Tag: v2.000000~3^2~119 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b5f725928b6acbd2d6aa44ae2cd481369dc4c52;p=dbsrgits%2FSQL-Abstract.git extract setop expansion --- diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index 341d9da..91c6179 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -87,22 +87,16 @@ sub apply_to { return $exp; }); }); - my $expand_setop = $self->cb(sub { - my ($self, $setop, $args) = @_; - +{ "-${setop}" => { - %$args, - queries => [ map $self->expand_expr($_), @{$args->{queries}} ], - } }; - }); - $sqla->expanders(map +($_ => $expand_setop), qw(union intersect except)); $sqla->clause_renderer('select.setop' => $self->cb(sub { my ($self, undef, $setop) = @_; $self->render_aqt($setop); })); - $sqla->renderer($_ => $self->cb('_render_setop')) - for qw(union intersect except); + foreach my $setop (qw(union intersect except)) { + $sqla->expander($setop => $self->cb('_expand_setop')); + $sqla->renderer($setop => $self->cb('_render_setop')); + } my $setop_expander = $self->cb(sub { my ($self, $setop, $args) = @_; @@ -333,6 +327,14 @@ sub _render_with { ); } +sub _expand_setop { + my ($self, $setop, $args) = @_; + +{ "-${setop}" => { + %$args, + queries => [ map $self->expand_expr($_), @{$args->{queries}} ], + } }; +} + sub _render_setop { my ($self, $setop, $args) = @_; $self->join_query_parts(