From: Peter Rabbitson Date: Sat, 7 Dec 2013 15:07:57 +0000 (+0100) Subject: Extra (now passing) oracle test which led to the work in 37b5ab51 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d07f715dddc9e64362a168cf05896e89002a1aca;p=dbsrgits%2FDBIx-Class-Historic.git Extra (now passing) oracle test which led to the work in 37b5ab51 Grumble - this was such a simple thing to diagnose and it took a month to see it. The culprit was the (correctly bisected to) cleanup in d87929a4, which failed to take into account that an empty connect() can still lead to a healthy $dbh, given system-based authoriozation, and no attributes being passed in. For the curious - the difficulty to diagnose was further exacerbated by the apparent insanity of what was being generated - a (known, existing) method name was somehow leaking into the generated SQL. In reality when we failed to determine the driver, we also failed to determine the SQLA subclass, which in turn made us call a nonexisting method on $sql_maker, but *surprise* - SQL::Abstract (the granddady of it all) defines an AUTOLOAD. Khaaaaaaaaaaaaa.... --- diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 568b561..dcb1b8f 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -644,7 +644,7 @@ sub relname_to_table_alias { my $alias = $self->next::method(@_); # we need to shorten here in addition to the shortening in SQLA itself, - # since the final relnames are a crucial for the join optimizer + # since the final relnames are crucial for the join optimizer return $self->sql_maker->_shorten_identifier($alias); } diff --git a/t/73oracle.t b/t/73oracle.t index 19634af..40dcaac 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -551,6 +551,26 @@ sub _run_tests { do_clean ($dbh2); }} +# test driver determination issues that led to the diagnosis/fix in 37b5ab51 +# observed side-effect when count-is-first on a fresh env-based connect + { + local $ENV{DBI_DSN}; + ($ENV{DBI_DSN}, my @user_pass_args) = @{ $schema->storage->connect_info }; + my $s2 = DBICTest::Schema->connect( undef, @user_pass_args ); + ok (! $s2->storage->connected, 'Not connected' ); + is (ref $s2->storage, 'DBIx::Class::Storage::DBI', 'Undetermined driver' ); + + ok ( + $s2->resultset('Artist')->search({ 'me.name' => { like => '%' } }, { prefetch => 'cds' })->count, + 'Some artist count' + ); + ok ( + scalar $s2->resultset('CD')->search({}, { join => 'tracks' } )->all, + 'Some cds returned' + ); + $s2->storage->disconnect; + } + do_clean ($dbh); }