From: Rafael Kitover Date: Fri, 5 Jun 2009 04:34:25 +0000 (+0000) Subject: shit doesn't work yet X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b55e97a74a1c2a74bf9f34685eb41216b12583de;p=dbsrgits%2FDBIx-Class-Historic.git shit doesn't work yet --- diff --git a/lib/DBIx/Class/ResultSource/Table.pm b/lib/DBIx/Class/ResultSource/Table.pm index cf263d1..90c9f9a 100644 --- a/lib/DBIx/Class/ResultSource/Table.pm +++ b/lib/DBIx/Class/ResultSource/Table.pm @@ -26,6 +26,9 @@ Returns the FROM entry for the table (i.e. the table name) =cut +use overload + '""' => \&from; + sub from { shift->name; } 1; diff --git a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm index 5180f96..8981f6a 100644 --- a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm @@ -4,6 +4,8 @@ use strict; use warnings; use base 'DBIx::Class::Storage::DBI'; +use Scalar::Util (); +use Carp::Clan qw/^DBIx::Class/; =head1 NAME @@ -39,7 +41,7 @@ Manually subs in the values for the usual C placeholders. sub _prep_for_execute { my $self = shift; - my ($op, $extra_bind, $ident) = @_; + my ($op, $extra_bind, $ident, $rsrc) = @_; my ($sql, $bind) = $self->next::method(@_); @@ -50,7 +52,12 @@ sub _prep_for_execute { foreach my $bound (@$bind) { my $col = shift @$bound; + my $datatype = 'FIXME!!!'; + +# this is what needs to happen: +# my $datatype = $rsrc->column_info($col)->{data_type}; + foreach my $data (@$bound) { if(ref $data) { $data = ''.$data; diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index ed6f75c..82d05dc 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -5,6 +5,7 @@ use base qw/ DBIx::Class::Storage::DBI::NoBindVars DBIx::Class::Storage::DBI::Sybase /; +use List::Util (); sub _dbh_last_insert_id { my ($self, $dbh, $source, $col) = @_; @@ -14,11 +15,10 @@ sub _dbh_last_insert_id { return ($dbh->selectrow_array('select @@identity'))[0]; } -my $noquote = { - int => qr/^ \-? \d+ $/x, - integer => qr/^ \-? \d+ $/x, +my %noquote = ( + int => sub { /^ -? \d+ \z/x }, # TODO maybe need to add float/real/etc -}; +); sub should_quote_data_type { my $self = shift; @@ -26,14 +26,14 @@ sub should_quote_data_type { return $self->next::method(@_) if not defined $value; - if (my $re = $noquote->{$type}) { - return 0 if $value =~ $re; + if (my $key = List::Util::first { $type =~ /^$_/i } keys %noquote) { + local $_ = $value; + return 0 if $noquote{$key}->(); } return $self->next::method(@_); } - 1; =head1 NAME