[Bast-commits] r5804 - in SQL-Abstract/1.x/trunk: lib/SQL t
dami at dev.catalyst.perl.org
dami at dev.catalyst.perl.org
Mon Mar 23 21:07:23 GMT 2009
Author: dami
Date: 2009-03-23 21:07:23 +0000 (Mon, 23 Mar 2009)
New Revision: 5804
Modified:
SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
SQL-Abstract/1.x/trunk/t/02where.t
Log:
fixed the failing tests
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm 2009-03-23 18:16:41 UTC (rev 5803)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm 2009-03-23 21:07:23 UTC (rev 5804)
@@ -452,15 +452,11 @@
$self->_SWITCH_refkind($v, {
ARRAYREF => sub {
- # LDNOTE : should deprecate {-or => [...]} and {-and => [...]}
- # because they are misleading; the only proper way would be
- # -nest => [-or => ...], -nest => [-and ...]
return $self->_where_ARRAYREF($v, $op eq 'NEST' ? '' : $op);
},
HASHREF => sub {
if ($op eq 'OR') {
- belch "-or => {...} should be -nest => [...]";
return $self->_where_ARRAYREF([%$v], 'OR');
}
else { # NEST | AND
@@ -594,18 +590,17 @@
if(@$vals) {
$self->_debug("ARRAY($vals) means multiple elements: [ @$vals ]");
-
-
- # LDNOTE : change the distribution logic when
+ # LDNOTE : had planned to change the distribution logic when
# $op =~ $self->{inequality_op}, because of Morgan laws :
# with {field => {'!=' => [22, 33]}}, it would be ridiculous to generate
# WHERE field != 22 OR field != 33 : the user probably means
# WHERE field != 22 AND field != 33.
- my $logic = ($op =~ $self->{inequality_op}) ? 'AND' : 'OR';
+ # To do this, replace the line below by :
+ # my $logic = ($op =~ $self->{inequality_op}) ? 'AND' : 'OR';
+ # return $self->_recurse_where([map { {$k => {$op, $_}} } @$vals], $logic);
# distribute $op over each member of @$vals
- return $self->_recurse_where([map { {$k => {$op, $_}} } @$vals], $logic);
-
+ return $self->_recurse_where([map { {$k => {$op, $_}} } @$vals]);
}
else {
# try to DWIM on equality operators
@@ -1648,20 +1643,10 @@
To test against multiple values, just enclose the values in an arrayref:
- status => { '!=', ['assigned', 'in-progress', 'pending'] };
+ status => { '=', ['assigned', 'in-progress', 'pending'] };
Which would give you:
- "WHERE status != ? AND status != ? AND status != ?"
-
-Notice that since the operator was recognized as being a 'negative'
-operator, the arrayref was interpreted with 'AND' logic (because
-of Morgan's laws). By contrast, the reverse
-
- status => { '=', ['assigned', 'in-progress', 'pending'] };
-
-would generate :
-
"WHERE status = ? OR status = ? OR status = ?"
Modified: SQL-Abstract/1.x/trunk/t/02where.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/02where.t 2009-03-23 18:16:41 UTC (rev 5803)
+++ SQL-Abstract/1.x/trunk/t/02where.t 2009-03-23 21:07:23 UTC (rev 5804)
@@ -156,6 +156,7 @@
},
{
+# LDNOTE 23.03.09 : modified test below, just parentheses differ
where => { foo => {-not_like => [7,8,9]},
fum => {'like' => [qw/a b/]},
nix => {'between' => [100,200] },
@@ -163,7 +164,7 @@
wix => {'in' => [qw/zz yy/]},
wux => {'not_in' => [qw/30 40/]}
},
- stmt => " WHERE ( ( ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) ) AND ( ( fum LIKE ? ) OR ( fum LIKE ? ) ) AND nix BETWEEN ? AND ? AND nox NOT BETWEEN ? AND ? AND wix IN ( ?, ? ) AND wux NOT IN ( ?, ? ) )",
+ stmt => " WHERE ( ( ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) ) AND ( ( fum LIKE ? ) OR ( fum LIKE ? ) ) AND ( nix BETWEEN ? AND ? ) AND ( nox NOT BETWEEN ? AND ? ) AND wix IN ( ?, ? ) AND wux NOT IN ( ?, ? ) )",
bind => [7,8,9,'a','b',100,200,150,160,'zz','yy','30','40'],
},
More information about the Bast-commits
mailing list