From: Rafael Kitover Date: Wed, 10 Jun 2009 13:27:41 +0000 (+0000) Subject: handle unknown rsrc in NoBindVars and Sybase::NoBindVars X-Git-Tag: v0.08112~14^2~136 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3c25a1db02464754437bcebef9cf5b93b733571;p=dbsrgits%2FDBIx-Class.git handle unknown rsrc in NoBindVars and Sybase::NoBindVars --- diff --git a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm index eac8295..0c1a083 100644 --- a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm @@ -62,7 +62,8 @@ sub _prep_for_execute { my $rsrc = $alias2src->{$alias}; - my $datatype = $rsrc->column_info($col)->{data_type}; + my $datatype = $rsrc ? $rsrc->column_info($col)->{data_type} : + '__UNKNOWN__'; foreach my $data (@$bound) { if(ref $data) { diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index 4ebb8cf..42c9018 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -39,6 +39,9 @@ sub should_quote_data_type { if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) { return 0 if $noquote{$key}->($value); + } elsif ($type eq '__UNKNOWN__') { +# try to guess based on value + return 0 if $number->($value) || $noquote->{money}->($value); } return $self->next::method(@_);