X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=906ed9784b7f0b40a88d32ae0594b2447fa63508;hb=9361b05d319e60314bf2caff1e96ff3c388a50bb;hp=f14eb972ca9aa64a90096f286b2b8f069bb4579b;hpb=90d7422fc60a3bad71cc67dc20106ef68046664e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index f14eb97..906ed97 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -92,6 +92,7 @@ my @rdbms_specific_methods = qw/ delete select select_single + with_deferred_fk_checks get_use_dbms_capability get_dbms_capability @@ -324,8 +325,8 @@ for most DBDs. See L for details. =head3 DBIx::Class specific connection attributes -In addition to the standard L -L attributes, DBIx::Class recognizes +In addition to the standard L +L attributes, DBIx::Class recognizes the following connection options. These options can be mixed in with your other L connection attributes, or placed in a separate hashref (C<\%extra_attributes>) as shown above. @@ -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( @@ -1459,6 +1465,15 @@ sub _prep_for_execute { }]; } + if ($op eq 'select' + && first { blessed($_->[1]) && $_->[1]->isa('DateTime') } @final_bind) { + + carp_unique 'DateTime objects passed to search() are not supported ' + . 'properly (InflateColumn::DateTime formats and settings are not ' + . 'respected.) See "Formatting DateTime objects in queries" in ' + . 'DBIx::Class::Manual::Cookbook'; + } + ($sql, \@final_bind); } @@ -1523,7 +1538,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 +2101,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 @@ -2221,16 +2242,6 @@ storage driver. Can be overridden by supplying an explicit L to L. For a list of available limit dialects see L. -=head2 sth - -=over 4 - -=item Arguments: $sql - -=back - -Returns a L sth (statement handle) for the supplied SQL. - =cut sub _dbh_sth { @@ -2867,7 +2878,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