Bugzilla – Attachment 23497 Details for
Bug 11389
re-enable PostgreSQL as a database scheme that Koha can connect to
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11389: reenable Pg as a DB scheme that Koha can connect to
Bug-11389-reenable-Pg-as-a-DB-scheme-that-Koha-can.patch (text/plain), 4.53 KB, created by
Galen Charlton
on 2013-12-13 00:07:46 UTC
(
hide
)
Description:
Bug 11389: reenable Pg as a DB scheme that Koha can connect to
Filename:
MIME Type:
Creator:
Galen Charlton
Created:
2013-12-13 00:07:46 UTC
Size:
4.53 KB
patch
obsolete
>From ebb1000bdecb1d931ab009927135e0af5ff918cd Mon Sep 17 00:00:00 2001 >From: Galen Charlton <gmc@esilibrary.com> >Date: Thu, 12 Dec 2013 23:55:14 +0000 >Subject: [PATCH] Bug 11389: reenable Pg as a DB scheme that Koha can connect > to > >This patch restores the ability to request a DBI database handle >or a DBIx::Class schema object connected to a PostgreSQL database. > >To address the concerns raised in bug 7188, only "mysql" and "Pg" >are recognized as valid DB schemes. If anything else is passed >to C4::Context::db_scheme2dbi or set as the db_scheme in the Koha >configuration file, the DBD driver to load is assumed to be "mysql". > >Note that this patch drops any pretense of Oracle support. > >To test: > >[1] Apply patch, and verify that the database-dependent tests > pass when run against a MySQL Koha database. >[2] To test against PostgreSQL, create a Pg database and > edit koha-conf.xml to set db_scheme to Pg (and adjust > the other DB connection parameters appropriately). The > following tests should pass, at minimum: > > t/Context.t > t/db_dependent/Koha_Database.t > >Signed-off-by: Galen Charlton <gmc@esilibrary.com> >--- > C4/Context.pm | 33 ++++++++++++++------------------- > Koha/Database.pm | 8 +------- > etc/koha-conf.xml | 1 + > t/Context.t | 7 ++++++- > 4 files changed, 22 insertions(+), 27 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 39927d4..a474237 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -292,20 +292,20 @@ sub memcached { > } > } > >-# db_scheme2dbi >-# Translates the full text name of a database into de appropiate dbi name >-# >+=head2 db_schema2dbi >+ >+ my $dbd_driver_name = C4::Context::db_schema2dbi($scheme); >+ >+This routines translates a database type to part of the name >+of the appropriate DBD driver to use when establishing a new >+database connection. It recognizes 'mysql' and 'Pg'; if any >+other scheme is supplied it defaults to 'mysql'. >+ >+=cut >+ > sub db_scheme2dbi { >- my $name = shift; >- # for instance, we support only mysql, so don't care checking >- return "mysql"; >- for ($name) { >-# FIXME - Should have other databases. >- if (/mysql/) { return("mysql"); } >- if (/Postgres|Pg|PostgresSQL/) { return("Pg"); } >- if (/oracle/) { return("Oracle"); } >- } >- return; # Just in case >+ my $scheme = shift // ''; >+ return $scheme eq 'Pg' ? $scheme : 'mysql'; > } > > sub import { >@@ -793,12 +793,7 @@ sub _new_dbh > > ## $context > ## correct name for db_schme >- my $db_driver; >- if ($context->config("db_scheme")){ >- $db_driver=db_scheme2dbi($context->config("db_scheme")); >- }else{ >- $db_driver="mysql"; >- } >+ my $db_driver = db_scheme2dbi($context->config("db_scheme")); > > my $db_name = $context->config("database"); > my $db_host = $context->config("hostname"); >diff --git a/Koha/Database.pm b/Koha/Database.pm >index 4c6cae6..12758bf 100644 >--- a/Koha/Database.pm >+++ b/Koha/Database.pm >@@ -45,14 +45,8 @@ __PACKAGE__->mk_accessors(qw( )); > # database connection from the data given in the current context, and > # returns it. > sub _new_schema { >- my $db_driver; > my $context = C4::Context->new(); >- if ( $context->config("db_scheme") ) { >- $db_driver = $context->db_scheme2dbi( $context->config("db_scheme") ); >- } >- else { >- $db_driver = "mysql"; >- } >+ my $db_driver = C4::Context::db_scheme2dbi($context->config("db_scheme")); > > my $db_name = $context->config("database"); > my $db_host = $context->config("hostname"); >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index d42f041..1da5378 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -264,6 +264,7 @@ __PAZPAR2_TOGGLE_XML_POST__ > > <!-- ADDITIONAL KOHA CONFIGURATION DIRECTIVE --> > <!-- db_scheme should follow the DBD driver name --> >+<!-- the DBD drivers supported by Koha are mysql and Pg --> > <!-- port info: mysql:3306 Pg:5432 (5433 on Debian) --> > <config> > <db_scheme>__DB_TYPE__</db_scheme> >diff --git a/t/Context.t b/t/Context.t >index 12d1675..93e11c4 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -2,9 +2,14 @@ > use strict; > use warnings; > use DBI; >-use Test::More tests => 1; >+use Test::More tests => 5; > use Test::MockModule; > > BEGIN { > use_ok('C4::Context'); > } >+ >+is(C4::Context::db_scheme2dbi('mysql'), 'mysql', 'ask for mysql, get mysql'); >+is(C4::Context::db_scheme2dbi('Pg'), 'Pg', 'ask for Pg, get Pg'); >+is(C4::Context::db_scheme2dbi('xxx'), 'mysql', 'ask for unsupported DBMS, get mysql'); >+is(C4::Context::db_scheme2dbi(), 'mysql', 'ask for nothing, get mysql'); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11389
:
23497
|
23885
|
24212