Switched storage from prepare to prepare_cached with an if_active of 3, as recommende...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI.pm
index 5c858ec..67c04a5 100644 (file)
@@ -114,10 +114,15 @@ sub _skip_options {
 
 sub _join_condition {
   my ($self, $cond) = @_;
-  die "no chance" unless ref $cond eq 'HASH';
-  my %j;
-  for (keys %$cond) { my $x = '= '.$self->_quote($cond->{$_}); $j{$_} = \$x; };
-  return $self->_recurse_where(\%j);
+  if (ref $cond eq 'HASH') {
+    my %j;
+    for (keys %$cond) { my $x = '= '.$self->_quote($cond->{$_}); $j{$_} = \$x; };
+    return $self->_recurse_where(\%j);
+  } elsif (ref $cond eq 'ARRAY') {
+    return join(' OR ', map { $self->_join_condition($_) } @$cond);
+  } else {
+    die "Can't handle this yet!";
+  }
 }
 
 sub _quote {
@@ -287,8 +292,8 @@ sub select_single {
 
 sub sth {
   my ($self, $sql, $op) = @_;
-  my $meth = (defined $op && $op ne 'select' ? 'prepare_cached' : 'prepare');
-  return $self->dbh->$meth($sql);
+  # 3 is the if_active parameter which avoids active sth re-use
+  return $self->dbh->prepare_cached($sql, {}, 3);
 }
 
 1;