From: Dan Kubb Date: Thu, 4 Aug 2005 16:42:04 +0000 (+0000) Subject: Bind values are passed into select query when no sth passed in X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20a2c9543ec0c19b46a0b4bab7dcc2d0cd9138a5;p=dbsrgits%2FDBIx-Class-Historic.git Bind values are passed into select query when no sth passed in Added use strict to DBIx::Class::Storage::DBI Removed hack that andyg added, and simplified execute in select --- diff --git a/lib/DBIx/Class/Cursor.pm b/lib/DBIx/Class/Cursor.pm index 4c59ff3..687c5a4 100644 --- a/lib/DBIx/Class/Cursor.pm +++ b/lib/DBIx/Class/Cursor.pm @@ -11,6 +11,7 @@ sub new { #use Data::Dumper; warn Dumper(@_); $it_class = ref $it_class if ref $it_class; unless ($sth) { + $attrs->{bind} = $args; $sth = $db_class->storage->select($db_class->_table_name,$cols, $attrs->{where},$attrs); } diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index cbd0ffe..623da44 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1,5 +1,7 @@ package DBIx::Class::Storage::DBI; +use strict; +use warnings; use DBI; use base qw/DBIx::Class/; @@ -83,7 +85,7 @@ sub insert { my $sql = $self->create_sql('insert', [ keys %{$to_insert} ], $ident, undef); my $sth = $self->sth($sql); $sth->execute(values %{$to_insert}); - $self->throw( "Couldn't insert ".join(%to_insert)." into ${ident}" ) + $self->throw( "Couldn't insert ".join(', ', map "$_ => $to_insert->{$_}", keys %$to_insert)." into ${ident}" ) unless $sth->rows; return $to_insert; } @@ -120,14 +122,7 @@ sub select { my $sql = $self->create_sql('select', $select, $ident, $cond_sql); #warn $sql.' '.join(', ', @{$attrs->{bind}||[]}); my $sth = $self->sth($sql); - if (@{$attrs->{bind}||[]}) { - $sth->execute( @{$attrs->{bind}||[]} ); - } else { - # disable unexplained 'Use of uninitialized value in subroutine entry' - # warnings - no warnings 'uninitialized'; - $sth->execute; - } + $sth->execute( @{$attrs->{bind}||[]} ); return $sth; }