Hi,

Here's a patch that fixes a problem with how IN queries are handled when
bind values are not used.  It was flattening scalar refs into strings
rather than de-referencing them, but only when binds are off.

I tried to follow your indentation style.  I shifted the bind variations
around a bit because it led to a bunch of duplicated code otherwise.
Couldn't figure out where this should go in the test suite, but if you
point me at something that does it for the binds I could try writing a
test for it.

- Perrin
--- /home/perrin/Desktop/Rose-DB-Object-0.742/lib/Rose/DB/Object/QueryBuilder.pm	2006-07-21 14:15:50.000000000 -0400
+++ lib/Rose/DB/Object/QueryBuilder.pm	2006-08-04 19:41:32.000000000 -0400
@@ -597,48 +597,48 @@
     {
       if($op eq '=')
       {
-        if($bind)
+        my @new_vals;
+
+        foreach my $val (@$vals)
         {
-          my @new_vals;
+          my $should_inline = 
+            ($db && $col_meta && $col_meta->should_inline_value($db, $val));
 
-          foreach my $val (@$vals)
+          if($should_inline || $force_inline)
           {
-            my $should_inline = 
-              ($db && $col_meta && $col_meta->should_inline_value($db, $val));
-
-            if($should_inline || $force_inline)
-            {
-              push(@new_vals, $val);
-            }
-            elsif(ref $val eq 'SCALAR')
-            {
-              push(@new_vals, $$val);
-            }
-            elsif(defined $val)
+            push(@new_vals, $val);
+          }
+          elsif(ref $val eq 'SCALAR')
+          {
+            push(@new_vals, $$val);
+          }
+          else
+          {
+            if($bind)
             {
-              push(@$bind, $val);
-              push(@new_vals, $placeholder);
+              if(defined $val)
+              {
+                push(@$bind, $val);
+                push(@new_vals, $placeholder);
 
-              if($bind_params)
+                if($bind_params)
+                {
+                  push(@$bind_params, $col_meta->dbi_bind_param_attrs($db));
+                }
+              }
+              else
               {
-                push(@$bind_params, $col_meta->dbi_bind_param_attrs($db));
+                push(@new_vals, 'NULL');
               }
             }
             else
             {
-              push(@new_vals, 'NULL');
+              push(@new_vals, $dbh->quote($val));
             }
           }
-
-          return "$field " . ($not ? "$not " : '') . 'IN (' . join(', ', @new_vals) . ')';
         }
 
-        return "$field " . ($not ? "$not " : '') . 'IN (' . join(', ', map 
-               {
-                 ($force_inline || ($db && $col_meta && $col_meta->should_inline_value($db, $_))) ? 
-                 $_ : $dbh->quote($_)
-               }
-               @$vals) . ')';
+        return "$field " . ($not ? "$not " : '') . 'IN (' . join(', ', @new_vals) . ')';
       }
       elsif($op =~ /^(A(?:NY|LL)) IN (SET|ARRAY)$/)
       {
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to