From: Peter Rabbitson Date: Thu, 27 Dec 2012 05:43:53 +0000 (+0100) Subject: Ensure _dbi_attrs_for_bind/bind_attribute_by_data_type are called after connecting X-Git-Tag: v0.08205~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ad7c50fc;p=dbsrgits%2FDBIx-Class.git Ensure _dbi_attrs_for_bind/bind_attribute_by_data_type are called after connecting This way a user does not have to worry about the particular DBI/DBD being loaded before accessing its constants --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 4ef923c..cc59419 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1697,14 +1697,17 @@ sub _execute { '_dbh_execute', $sql, $bind, - $self->_dbi_attrs_for_bind($ident, $bind) + $ident, ); } sub _dbh_execute { - my ($self, undef, $sql, $bind, $bind_attrs) = @_; + my ($self, undef, $sql, $bind, $ident) = @_; $self->_query_start( $sql, $bind ); + + my $bind_attrs = $self->_dbi_attrs_for_bind($ident, $bind); + my $sth = $self->_sth($sql); for my $i (0 .. $#$bind) { @@ -2584,7 +2587,10 @@ Given a datatype from column info, returns a database specific bind attribute for C<< $dbh->bind_param($val,$attribute) >> or nothing if we will let the database planner just handle it. -Generally only needed for special case column types, like bytea in postgres. +This method is always called after the driver has been determined and a DBI +connection has been established. Therefore you can refer to C +and/or C directly, without worrying about loading +the correct modules. =cut diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index 1bf0e25..14c07d2 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -191,7 +191,7 @@ sub deployment_statements { sub bind_attribute_by_data_type { $_[1] =~ /^ (?: int(?:eger)? | (?:tiny|small|medium)int ) $/ix - ? do { require DBI; DBI::SQL_INTEGER() } + ? DBI::SQL_INTEGER() : undef ; }