Skip to content

Commit

Permalink
Switch from "use base" to a method which can run more than once
Browse files Browse the repository at this point in the history
RT::Handle->FinalizeDatabaseType is called when the package is
require'd, thanks to the final lines of RT::Handle.  This means that it
is always called in RT::Test->bookstrap_db, which is always called on
'use RT::Test'.  Furthermore, "use base ..." will only have an effect
_once_.  As such, in t/web/install.t, the "SQLite" handle is actually
still an DBIx::SearchBuilder::Handle::Oracle despite DatabaseType being
SQLite.  This leads to the SystemDSN being
dbi:SQLite:sid=/path/to/rt4test_install_xxx;host=hostname;port=1521
which fares about as well as you might expect.

Switch to setting the parentage via an explicit require and @isa, which
can be called more than once.
  • Loading branch information
alexmv committed Nov 13, 2013
1 parent 0fdcbee commit a2314ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/RT/Handle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ L<DBIx::SearchBuilder::Handle>, using the C<DatabaseType> configuration.
=cut

sub FinalizeDatabaseType {
eval {
use base "DBIx::SearchBuilder::Handle::". RT->Config->Get('DatabaseType');
};

my $db_type = RT->Config->Get('DatabaseType');
if ($@) {
my $package = "DBIx::SearchBuilder::Handle::$db_type";

unless (eval "require $package; 1;") {
die "Unable to load DBIx::SearchBuilder database handle for '$db_type'.\n".
"Perhaps you've picked an invalid database type or spelled it incorrectly.\n".
$@;
}

@RT::Handle::ISA = ($package);

# We use COLLATE NOCASE to enforce case insensitivity on the normally
# case-sensitive SQLite, LOWER() approach works, but lucks performance
# due to absence of functional indexes
Expand Down

0 comments on commit a2314ce

Please sign in to comment.