Trailing WS crusade - got to save them bits
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI.pm
index f14eb97..b9d7489 100644 (file)
@@ -92,6 +92,7 @@ my @rdbms_specific_methods = qw/
   delete
   select
   select_single
+  with_deferred_fk_checks
 
   get_use_dbms_capability
   get_dbms_capability
@@ -1359,7 +1360,7 @@ sub txn_commit {
   # as a new txn is started immediately on commit
   $self->transaction_depth(1) if (
     !$self->transaction_depth
-      and 
+      and
     defined $self->_dbh_autocommit
       and
     ! $self->_dbh_autocommit
@@ -1390,7 +1391,7 @@ sub txn_rollback {
   # as a new txn is started immediately on commit
   $self->transaction_depth(1) if (
     !$self->transaction_depth
-      and 
+      and
     defined $self->_dbh_autocommit
       and
     ! $self->_dbh_autocommit
@@ -1417,6 +1418,11 @@ for my $meth (qw/svp_begin svp_release svp_rollback/) {
 #  easier to override in NoBindVars without duping the rest.  It takes up
 #  all of _execute's args, and emits $sql, @bind.
 sub _prep_for_execute {
+  #my ($self, $op, $ident, $args) = @_;
+  return shift->_gen_sql_bind(@_)
+}
+
+sub _gen_sql_bind {
   my ($self, $op, $ident, $args) = @_;
 
   my ($sql, @bind) = $self->sql_maker->$op(
@@ -1523,7 +1529,13 @@ sub _dbi_attrs_for_bind {
         $_->{dbd_attrs}
       }
       elsif($_->{sqlt_datatype}) {
-        $self->bind_attribute_by_data_type($_->{sqlt_datatype}) || undef;
+        # cache the result in the dbh_details hash, as it can not change unless
+        # we connect to something else
+        my $cache = $self->_dbh_details->{_datatype_map_cache} ||= {};
+        if (not exists $cache->{$_->{sqlt_datatype}}) {
+          $cache->{$_->{sqlt_datatype}} = $self->bind_attribute_by_data_type($_->{sqlt_datatype}) || undef;
+        }
+        $cache->{$_->{sqlt_datatype}};
       }
       elsif ($sba_attrs and $_->{dbic_colname}) {
         $sba_attrs->{$_->{dbic_colname}} || undef;
@@ -2080,8 +2092,8 @@ sub _select_args_to_query {
   my ($op, $ident, @args) =
     $self->_select_args(@_);
 
-  # my ($sql, $prepared_bind) = $self->_prep_for_execute($op, $ident, [ $select, $cond, $rs_attrs, $rows, $offset ]);
-  my ($sql, $prepared_bind) = $self->_prep_for_execute($op, $ident, \@args);
+  # my ($sql, $prepared_bind) = $self->_gen_sql_bind($op, $ident, [ $select, $cond, $rs_attrs, $rows, $offset ]);
+  my ($sql, $prepared_bind) = $self->_gen_sql_bind($op, $ident, \@args);
   $prepared_bind ||= [];
 
   return wantarray
@@ -2867,7 +2879,7 @@ sub _max_column_bytesize {
       if ($data_type =~ /^(?:
           l? (?:var)? char(?:acter)? (?:\s*varying)?
             |
-          (?:var)? binary (?:\s*varying)? 
+          (?:var)? binary (?:\s*varying)?
             |
           raw
         )\b/x