From: Matt S Trout Date: Mon, 23 Sep 2019 01:46:53 +0000 (+0000) Subject: extract setop expander X-Git-Tag: v2.000000~3^2~118 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0f4de0296bcb598c0bcc697acd8090977d67b34a;p=dbsrgits%2FSQL-Abstract.git extract setop expander --- diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index 91c6179..27f88f9 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -98,16 +98,7 @@ sub apply_to { $sqla->renderer($setop => $self->cb('_render_setop')); } - my $setop_expander = $self->cb(sub { - my ($self, $setop, $args) = @_; - my ($op, $type) = split '_', $setop; - +(setop => $self->expand_expr({ - "-${op}" => { - ($type ? (type => $type) : ()), - queries => (ref($args) eq 'ARRAY' ? $args : [ $args ]) - } - })); - }); + my $setop_expander = $self->cb('_expand_clause_setop'); $sqla->clause_expanders( map +($_ => $setop_expander), @@ -343,4 +334,15 @@ sub _render_setop { ); } +sub _expand_clause_setop { + my ($self, $setop, $args) = @_; + my ($op, $type) = split '_', $setop; + +(setop => $self->expand_expr({ + "-${op}" => { + ($type ? (type => $type) : ()), + queries => (ref($args) eq 'ARRAY' ? $args : [ $args ]) + } + })); +} + 1;