[Bast-commits] r6009 - in SQL-Abstract/1.x/trunk: . lib/SQL
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Tue Apr 28 22:02:11 GMT 2009
Author: ribasushi
Date: 2009-04-28 23:02:11 +0100 (Tue, 28 Apr 2009)
New Revision: 6009
Modified:
SQL-Abstract/1.x/trunk/
SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
Log:
r5977 at Thesaurus (orig r5976): arcanez | 2009-04-24 10:03:45 +0200
fix for x => { '!=' => [ -and => (1 .. 3) ] }
added parens for test
r5981 at Thesaurus (orig r5980): arcanez | 2009-04-24 18:52:50 +0200
remove parens from test, they do not matter
r6004 at Thesaurus (orig r6003): ribasushi | 2009-04-28 23:01:46 +0200
Revert r5976, trying something better
r6008 at Thesaurus (orig r6007): ribasushi | 2009-04-28 23:57:54 +0200
A much better fix for the x => [ -and, ... ] corner case
Property changes on: SQL-Abstract/1.x/trunk
___________________________________________________________________
Name: svk:merge
- b9bda2dc-4395-4011-945f-8c81d782bde1:/branches/matthewt:18
b9bda2dc-4395-4011-945f-8c81d782bde1:/trunk:23
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/SQL-Abstract/1.x/branches/and_or:5969
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/SQL-Abstract:3093
+ b9bda2dc-4395-4011-945f-8c81d782bde1:/branches/matthewt:18
b9bda2dc-4395-4011-945f-8c81d782bde1:/trunk:23
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/SQL-Abstract/1.x/branches/and_or:6008
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/SQL-Abstract:3093
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm 2009-04-28 22:01:31 UTC (rev 6008)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract.pm 2009-04-28 22:02:11 UTC (rev 6009)
@@ -607,17 +607,25 @@
if(@$vals) {
$self->_debug("ARRAY($vals) means multiple elements: [ @$vals ]");
+ # see if the first element is an -and/-or op
+ my $logic;
+ if ($vals->[0] =~ /^ - ( AND|OR ) $/ix) {
+ $logic = uc $1;
+ shift @$vals;
+ }
+
+ # distribute $op over each remaining member of @$vals, append logic if exists
+ return $self->_recurse_where([map { {$k => {$op, $_}} } @$vals], $logic);
+
# 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.
- # To do this, replace the line below by :
+ # To do this, replace the above to roughly :
# 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]);
}
else {
# try to DWIM on equality operators
More information about the Bast-commits
mailing list