Changed behaviour to not stringify blessed objects, but pass them through to the...
[scpubgit/Q-Branch.git] / lib / SQL / Abstract.pm
index 90cf77d..8034548 100644 (file)
@@ -8,13 +8,16 @@ package SQL::Abstract; # see doc at end of file
 use Carp;
 use strict;
 use warnings;
-use List::Util qw/first/;
+use List::Util   qw/first/;
+use Scalar::Util qw/blessed/;
 
 #======================================================================
 # GLOBALS
 #======================================================================
 
 our $VERSION  = '1.49_01';
+$VERSION      = eval $VERSION; # numify for warning-free dev releases
+
 
 our $AUTOLOAD;
 
@@ -323,7 +326,13 @@ sub _recurse_where {
 
   # dispatch on appropriate method according to refkind of $where
   my $method = $self->_METHOD_FOR_refkind("_where", $where);
-  $self->$method($where, $logic); 
+
+
+  my ($sql, @bind) =  $self->$method($where, $logic); 
+
+  # DBIx::Class directly calls _recurse_where in scalar context, so 
+  # we must implement it, even if not in the official API
+  return wantarray ? ($sql, @bind) : $sql; 
 }
 
 
@@ -705,6 +714,7 @@ sub _order_by {
     ARRAYREF => sub {
       map {$self->_SWITCH_refkind($_, {
               SCALAR    => sub {$self->_quote($_)},
+              UNDEF     => sub {},
               SCALARREF => sub {$$_}, # literal SQL, no quoting
               HASHREF   => sub {$self->_order_by_hash($_)}
              }) } @$arg;
@@ -864,8 +874,11 @@ sub _refkind {
 
   # $suffix = 'REF' x (length of ref chain, i. e. \\[] is REFREFREF)
   while (1) {
+    # blessed references are considered like scalars
+    last if blessed $data;
     $suffix .= 'REF';
     $ref     = ref $data;
+
     last if $ref ne 'REF';
     $data = $$data;
   }