X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=91ea170d3334f58401cbc0a9e9b7f5dd69ad0b1f;hb=d047d650648a9566e84ca994cf699eebaf0cd156;hp=4f280ee8cd44784fbebfd33c50b88282cdd7956f;hpb=7ffb42e7b7638da131aa4ca823df9a0040a94185;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 4f280ee..91ea170 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1601,9 +1601,9 @@ sub _adjust_select_args_for_complex_prefetch { # alias any functions to the dbic-side 'as' label # adjust the outer select accordingly - if (ref $sel eq 'HASH' && !$sel->{-select}) { - $sel = { -select => $sel, -as => $attrs->{as}[$i] }; - $select->[$i] = join ('.', $attrs->{alias}, ($attrs->{as}[$i] || "select_$i") ); + if (ref $sel eq 'HASH' ) { + $sel->{-as} ||= $attrs->{as}[$i]; + $select->[$i] = join ('.', $attrs->{alias}, ($sel->{-as} || "select_$i") ); } push @$sub_select, $sel; @@ -2041,6 +2041,13 @@ Returns the database driver name. sub sqlt_type { shift->_get_dbh->{Driver}->{Name} } +# By default there is no resolution of DBIC data types to DBI data types +# In essence this makes e.g. AutoCast a noop +sub _dbi_data_type { + #my ($self, $data_type) = @_; + return undef +}; + =head2 bind_attribute_by_data_type Given a datatype from column info, returns a database specific bind @@ -2303,18 +2310,18 @@ sub deployment_statements { . $self->_check_sqlt_message . q{'}) if !$self->_check_sqlt_version; - require SQL::Translator::Parser::DBIx::Class; - eval qq{use SQL::Translator::Producer::${type}}; - $self->throw_exception($@) if $@; - # sources needs to be a parser arg, but for simplicty allow at top level # coming in $sqltargs->{parser_args}{sources} = delete $sqltargs->{sources} if exists $sqltargs->{sources}; - my $tr = SQL::Translator->new(%$sqltargs); - SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema ); - return "SQL::Translator::Producer::${type}"->can('produce')->($tr); + my $tr = SQL::Translator->new( + producer => "SQL::Translator::Producer::${type}", + %$sqltargs, + parser => 'SQL::Translator::Parser::DBIx::Class', + data => $schema, + ); + return $tr->translate; } sub deploy { @@ -2431,8 +2438,13 @@ sub lag_behind_master { sub DESTROY { my $self = shift; - return if !$self->_dbh; - $self->_verify_pid; + $self->_verify_pid if $self->_dbh; + + # some databases need this to stop spewing warnings + if (my $dbh = $self->_dbh) { + eval { $dbh->disconnect }; + } + $self->_dbh(undef); }