From: Matt S Trout Date: Sun, 16 Sep 2018 23:58:26 +0000 (+0000) Subject: start of moving and/or to ops X-Git-Tag: v1.90_01~454 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77617257225dda6e402c4bc4ab20b991cb5ff246;p=dbsrgits%2FSQL-Abstract.git start of moving and/or to ops --- diff --git a/lib/Data b/lib/Data new file mode 120000 index 0000000..8ac3e7e --- /dev/null +++ b/lib/Data @@ -0,0 +1 @@ +/home/matthewt/wdir/Data-Query/lib/Data \ No newline at end of file diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 4473764..c75bd6f 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -545,7 +545,8 @@ sub _expand_expr { if (ref($expr) eq 'HASH') { if (keys %$expr > 1) { $logic ||= 'and'; - return +{ "-${logic}" => [ + return +{ -op => [ + $logic, map $self->_expand_expr_hashpair($_ => $expr->{$_}, $logic), sort keys %$expr ] }; @@ -1288,8 +1289,12 @@ sub _where_op_OP { return (($op eq 'not' ? '('.$final_sql.')' : $final_sql), @bind); } else { my @parts = map [ $self->_recurse_where($_) ], @args; + my ($final_sql) = map +($op =~ /^(and|or)$/ ? "(${_})" : $_), join( + ' '.$self->_sqlcase($final_op).' ', + map $_->[0], @parts + ); return ( - join(' '.$self->_sqlcase($final_op).' ', map $_->[0], @parts), + $final_sql, map @{$_}[1..$#$_], @parts ); } diff --git a/lib/SQL/Abstract/Test.pm b/lib/SQL/Abstract/Test.pm index 8eeab4c..343b1fa 100644 --- a/lib/SQL/Abstract/Test.pm +++ b/lib/SQL/Abstract/Test.pm @@ -119,6 +119,11 @@ sub _sql_differ_diag { my $sql1 = shift || ''; my $sql2 = shift || ''; + if (my $profile = $ENV{SQL_ABSTRACT_TEST_TREE_PROFILE}) { + my $sqlat = SQL::Abstract::Tree->new(profile => $profile); + $_ = $sqlat->format($_) for ($sql1, $sql2); + } + $tb->${\($tb->in_todo ? 'note' : 'diag')} ( "SQL expressions differ\n" ." got: $sql1\n"