summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-05-29 12:02:45 +0200
committermkanat%bugzilla.org <>2006-05-29 12:02:45 +0200
commitc922073c79f949a867827e4f302d2ec433bbe85e (patch)
tree4a658cc551009ff62185d08301fdc4c0b3c85cc2 /Bugzilla/DB.pm
parent7adc23f4c0b17143d2ba9f8dab4d6a37981ef688 (diff)
downloadbugzilla-c922073c79f949a867827e4f302d2ec433bbe85e.tar.gz
bugzilla-c922073c79f949a867827e4f302d2ec433bbe85e.tar.xz
Bug 302876: Database Version-Checking needs to be more modular and more generic
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wicked, a=myk
Diffstat (limited to 'Bugzilla/DB.pm')
-rw-r--r--Bugzilla/DB.pm37
1 files changed, 8 insertions, 29 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 127218843..4a0099db4 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -48,6 +48,7 @@ use base qw(Exporter DBI::db);
Exporter::export_ok_tags('deprecated');
use Bugzilla::Config qw(:DEFAULT :db);
+use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::DB::Schema;
@@ -164,14 +165,11 @@ sub connect_main {
sub _connect {
my ($driver, $host, $dbname, $port, $sock, $user, $pass) = @_;
- # DB specific module have the same name as DB driver, here we
- # just make sure we are not case sensitive
- (my $db_module = $driver) =~ s/(\w+)/\u\L$1/g;
- my $pkg_module = "Bugzilla::DB::" . $db_module;
+ my $pkg_module = DB_MODULE->{lc($driver)}->{db};
# do the actual import
eval ("require $pkg_module")
- || die ("'$db_module' is not a valid choice for \$db_driver in "
+ || die ("'$driver' is not a valid choice for \$db_driver in "
. " localconfig: " . $@);
# instantiate the correct DB specific module
@@ -622,8 +620,9 @@ sub bz_rename_column {
sub _bz_schema {
my ($self) = @_;
return $self->{private_bz_schema} if exists $self->{private_bz_schema};
- $self->{private_bz_schema} =
- Bugzilla::DB::Schema->new($self->MODULE_NAME);
+ my @module_parts = split('::', ref $self);
+ my $module_name = pop @module_parts;
+ $self->{private_bz_schema} = Bugzilla::DB::Schema->new($module_name);
return $self->{private_bz_schema};
}
@@ -989,28 +988,6 @@ constants are required to be subroutines or "use constant" variables.
The C<\%attr> argument that must be passed to bind_param in order to
correctly escape a C<LONGBLOB> type.
-=item C<REQUIRED_VERSION>
-
-This is the minimum required version of the database server that the
-Bugzilla::DB subclass requires. It should be in a format suitable for
-passing to vers_cmp during installation.
-
-=item C<PROGRAM_NAME>
-
-The human-readable name of this database. For example, for MySQL, this
-would be 'MySQL.' You should not depend on this variable to know what
-type of database you are running on; this is intended merely for displaying
-to the admin to let them know what DB they're running.
-
-=item C<MODULE_NAME>
-
-The name of the Bugzilla::DB module that we are. For example, for the MySQL
-Bugzilla::DB module, this would be "Mysql." For PostgreSQL it would be "Pg."
-
-=item C<DBD_VERSION>
-
-The minimum version of the DBD module that we require for this database.
-
=back
@@ -1559,4 +1536,6 @@ PopGlobalSQLState
L<DBI>
+L<Bugzilla::Constants> - The C<DB_MODULE> constant.
+
=cut