our @EXPORT = qw(
perl_scalar_value perl_operator Literal Identifier compose intersperse
- scan_dq_nodes
+ scan_dq_nodes map_dq_tree
);
sub intersperse { my $i = shift; my @i = map +($_, $i), @_; pop @i; @i }
}
}
+sub map_dq_tree (&;@) {
+ my ($block, $in) = @_;
+ local $_ = $in;
+ $_ = $block->($_) if ref($_) eq 'HASH';
+ if (ref($_) eq 'REF' and ref($$_) eq 'HASH') {
+ $$_;
+ } elsif (ref($_) eq 'HASH') {
+ my $mapped = $_;
+ local $_;
+ +{ map +($_ => &map_dq_tree($block, $mapped->{$_})), keys %$mapped };
+ } elsif (ref($_) eq 'ARRAY') {
+ [ map &map_dq_tree($block, $_), @$_ ]
+ } else {
+ $_
+ }
+}
+
1;
package Data::Query::Renderer::SQL::MySQL;
-sub map_descending (&;@) {
- my ($block, $in) = @_;
- local $_ = $in;
- $_ = $block->($_) if ref($_) eq 'HASH';
- if (ref($_) eq 'REF' and ref($$_) eq 'HASH') {
- $$_;
- } elsif (ref($_) eq 'HASH') {
- my $mapped = $_;
- local $_;
- +{ map +($_ => &map_descending($block, $mapped->{$_})), keys %$mapped };
- } elsif (ref($_) eq 'ARRAY') {
- [ map &map_descending($block, $_), @$_ ]
- } else {
- $_
- }
-}
-
use Data::Query::Constants;
use Data::Query::ExprHelpers;
use Moo;
my $new = { %$dq };
foreach my $key (qw(set where)) {
next unless $dq->{$key};
- $new->{$key} = map_descending {
+ $new->{$key} = map_dq_tree {
if (is_Select) {
my $found;
scan_dq_nodes(do {