From: Peter Rabbitson Date: Wed, 26 Aug 2009 16:08:24 +0000 (+0000) Subject: Make sure sqlt_type gets called after determining driver X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eabde904f520c3d68eb83235f02610b021b221c0;p=dbsrgits%2FDBIx-Class-Historic.git Make sure sqlt_type gets called after determining driver --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index be1d64d..3be0981 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2084,7 +2084,16 @@ Returns the database driver name. =cut -sub sqlt_type { shift->_get_dbh->{Driver}->{Name} } +sub sqlt_type { + my ($self) = @_; + + if (not $self->_driver_determined) { + $self->_determine_driver; + goto $self->can ('sqlt_type'); + } + + $self->_get_dbh->{Driver}->{Name}; +} =head2 bind_attribute_by_data_type diff --git a/t/72pg.t b/t/72pg.t index b53916b..e382a87 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -50,8 +50,15 @@ plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test '. unless ($dsn && $user); DBICTest::Schema->load_classes( 'Casecheck', 'ArrayTest' ); -my $schema = DBICTest::Schema->connect($dsn, $user, $pass,); +{ + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); + + ok (!$schema->storage->_dbh, 'definitely not connected'); + is ($schema->storage->sqlt_type, 'PostgreSQL', 'sqlt_type correct pre-connection'); +} + +my $schema = DBICTest::Schema->connect($dsn, $user, $pass); # Check that datetime_parser returns correctly before we explicitly connect. SKIP: { eval { require DateTime::Format::Pg };