From: Matt S Trout Date: Mon, 23 Sep 2019 01:46:53 +0000 (+0000) Subject: extract setop expander X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=41086177ba1f6933a58673c79af6770fba80700e;p=scpubgit%2FQ-Branch.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;