[Bast-commits] r4766 - in DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage: . DBI

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Sun Aug 24 16:29:27 BST 2008


Author: matthewt
Date: 2008-08-24 16:29:27 +0100 (Sun, 24 Aug 2008)
New Revision: 4766

Modified:
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
Log:
first cut at vairable bind vars for sybase

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm	2008-08-24 14:56:31 UTC (rev 4765)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm	2008-08-24 15:29:27 UTC (rev 4766)
@@ -38,6 +38,9 @@
 
 sub _prep_for_execute {
   my $self = shift;
+
+  my ($op, $extra_bind, $ident) = @_;
+
   my ($sql, $bind) = $self->next::method(@_);
 
   # stringify args, quote via $dbh, and manually insert
@@ -46,12 +49,14 @@
   my $new_sql;
 
   foreach my $bound (@$bind) {
-    shift @$bound;
+    my $col = shift @$bound;
+    my $do_quote = $self->should_quote_data_type($col);
     foreach my $data (@$bound) {
         if(ref $data) {
             $data = ''.$data;
         }
-        $new_sql .= shift(@sql_part) . $self->_dbh->quote($data);
+        $data = $self->_dbh->quote($data) if $do_quote;
+        $new_sql .= shift(@sql_part) . $data;
     }
   }
   $new_sql .= join '', @sql_part;
@@ -59,6 +64,8 @@
   return ($new_sql);
 }
 
+sub should_quote_data_type { 1 }
+
 =head1 AUTHORS
 
 Brandon Black <blblack at gmail.com>

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2008-08-24 14:56:31 UTC (rev 4765)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2008-08-24 15:29:27 UTC (rev 4766)
@@ -5,6 +5,15 @@
 
 use base qw/DBIx::Class::Storage::DBI::NoBindVars/;
 
+my %noquote = map ($_ => 1), qw(int integer);
+
+sub should_quote_data_type {
+  my $self = shift;
+  my ($type) = @_;
+  return 0 if $noquote{$type};
+  return $self->next::method(@_);
+}
+
 1;
 
 =head1 NAME

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm	2008-08-24 14:56:31 UTC (rev 4765)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm	2008-08-24 15:29:27 UTC (rev 4766)
@@ -1055,6 +1055,10 @@
 #  all of _execute's args, and emits $sql, @bind.
 sub _prep_for_execute {
   my ($self, $op, $extra_bind, $ident, $args) = @_;
+  
+  if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+    $ident = $ident->from();
+  }
 
   my ($sql, @bind) = $self->sql_maker->$op($ident, @$args);
   unshift(@bind,
@@ -1101,10 +1105,6 @@
 
 sub _dbh_execute {
   my ($self, $dbh, $op, $extra_bind, $ident, $bind_attributes, @args) = @_;
-  
-  if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
-    $ident = $ident->from();
-  }
 
   my ($sql, $bind) = $self->_prep_for_execute($op, $extra_bind, $ident, \@args);
 




More information about the Bast-commits mailing list