[Bug 11891] New: Make Koha::Schema use C4::Context->dbh
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Bug ID: 11891 Summary: Make Koha::Schema use C4::Context->dbh Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: gmcharlt@gmail.com Reporter: kyle@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org Right now there is no connection between the database handles used by C4::Context::dbh and Koha::Datbase/Schema. This makes it impossible to use transactions in unit tests to temporarily modify the database to test subroutines that take advantage of Koha::Database. This patch fixes that issue. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 --- Comment #1 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 25828 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=25828&action=edit Bug 11891 - Make Koha::Schema use C4::Context->dbh Right now there is no connection between the database handles used by C4::Context::dbh and Koha::Datbase/Schema. This makes it impossible to use transactions in unit tests to temporarily modify the database to test subroutines that take advantage of Koha::Database. This patch fixes that issue. Test Plan: 1) Apply the patch for bug 11634 2) prove t/db_dependent/Circulation.t should fail 3) Apply this patch 4) prove t/db_dependent/Circulation.t should not fail -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #25828|0 |1 is obsolete| | --- Comment #2 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 25829 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=25829&action=edit Bug 11891 - Make Koha::Schema use C4::Context->dbh Right now there is no connection between the database handles used by C4::Context::dbh and Koha::Datbase/Schema. This makes it impossible to use transactions in unit tests to temporarily modify the database to test subroutines that take advantage of Koha::Database. This patch fixes that issue. Test Plan: 1) Apply the patch for bug 11634 2) prove t/db_dependent/Circulation.t should fail 3) Apply this patch 4) prove t/db_dependent/Circulation.t should not fail -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |11634 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion CC| |gmcharlt@gmail.com --- Comment #3 from Galen Charlton <gmcharlt@gmail.com> --- I'm immediately putting this into discussion, as I'm exploring the reverse: letting DBIC manage the storage handlers. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl --- Comment #4 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Galen Charlton from comment #3)
I'm immediately putting this into discussion, as I'm exploring the reverse: letting DBIC manage the storage handlers.
I would think too that we should move in the direction from C4 to Koha instead of the other way around. Let C4::Context ask a handle from the DBIC based classes during the transition phase. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 --- Comment #5 from Kyle M Hall <kyle@bywatersolutions.com> --- I also agree that is a more sensible long term approach than this one. (In reply to M. de Rooy from comment #4)
(In reply to Galen Charlton from comment #3)
I'm immediately putting this into discussion, as I'm exploring the reverse: letting DBIC manage the storage handlers.
I would think too that we should move in the direction from C4 to Koha instead of the other way around. Let C4::Context ask a handle from the DBIC based classes during the transition phase.
-- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |9011 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@biblibre.co | |m --- Comment #6 from Jonathan Druart <jonathan.druart@biblibre.com> --- Galen, do you progress on the other solution? In my opinion this patch could be pushed as it since it fixes some unit test failures (on master and 3.14, see t/db_dependent/Circulation_issue.t). The other way to do could be implemented later, don't you think? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Yohann Dufour <yohann.dufour@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yohann.dufour@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #25829|0 |1 is obsolete| | --- Comment #7 from Galen Charlton <gmcharlt@gmail.com> --- Created attachment 28962 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28962&action=edit Bug 11891: set up tests to require that Koha::Database uses same DB handle as C4::Context This patch removes changes in two cases to work around the fact that Koha::Database and C4::Context were not using the same DBI database handle. To test: [1] Run prove -v t/db_dependent/ILSDI_Services.t and prove -v t/db_dependent/Items.t. Both tests should fail. [2] Apply the main patches and run step 1 again. This time, both tests should pass. Signed-off-by: Galen Charlton <gmc@esilibrary.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 --- Comment #8 from Galen Charlton <gmcharlt@gmail.com> --- Created attachment 28963 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28963&action=edit Bug 11891 - Make Koha::Schema use C4::Context->dbh Right now there is no connection between the database handles used by C4::Context::dbh and Koha::Datbase/Schema. This makes it impossible to use transactions in unit tests to temporarily modify the database to test subroutines that take advantage of Koha::Database. This patch fixes that issue. Test Plan: 1) Apply this patch 2) prove -v t/db_dependent/ILSDI_Services.t and prove -v t/db_dependent/Items.t and prove -v t/db_dependent/Circulation_issue.t should all start passing Signed-off-by: Galen Charlton <gmc@esilibrary.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 --- Comment #9 from Galen Charlton <gmcharlt@gmail.com> --- Created attachment 28964 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28964&action=edit Bug 11891: (follow-up) remove custom storage class For now, just rely on the normal DBIx::Class cleanup handler; otherwise, the following warning is displayed in logs: (in cleanup) Can't locate object method "_preserve_foreign_dbh" via package "Koha::Storage" at .../Koha/Storage.pm Using the default DBIC storage class also means that we don't have to manually do things like set the SQL limit dialect; meaning that we don't get the following warning message: DBIx::Class::ResultSet::find(): Your storage class (Koha::Storage) does not set sql_limit_dialect and you have not supplied an explicit limit_dialect in your connection_info. DBIC will attempt to use the GenericSubQ dialect, which works on most databases but can be (and often is) painfully slow. Please file an RT ticket against 'Koha::Storage' . at /home/gmc/koha/C4/Members.pm line 840 Test plan: same as main patch Signed-off-by: Galen Charlton <gmc@esilibrary.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 --- Comment #10 from Galen Charlton <gmcharlt@gmail.com> --- Created attachment 28965 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28965&action=edit Bug 11891: (follow-up) set DBIC storage flags correctly Since we're passing an existing DBI database handle to DBIC, and that handle doesn't have RaiseError set to true by default, don't let DBIC override that -- for now. Test plan: verify that the DB-dependent test suite passes. Signed-off-by: Galen Charlton <gmc@esilibrary.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 --- Comment #11 from Galen Charlton <gmcharlt@gmail.com> --- OK, I've finally finished testing. Running with Kyle's approach for now, but with follow-ups that ensure that more things are tested, that the RaiseError behavior doesn't change unexpectedly, and that it doesn't default to generating inefficient SQL statements involving a LIMIT. Signed off. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28962|0 |1 is obsolete| | --- Comment #12 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 28966 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28966&action=edit Bug 11891: set up tests to require that Koha::Database uses same DB handle as C4::Context This patch removes changes in two cases to work around the fact that Koha::Database and C4::Context were not using the same DBI database handle. To test: [1] Run prove -v t/db_dependent/ILSDI_Services.t and prove -v t/db_dependent/Items.t. Both tests should fail. [2] Apply the main patches and run step 1 again. This time, both tests should pass. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28963|0 |1 is obsolete| | --- Comment #13 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 28967 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28967&action=edit Bug 11891 - Make Koha::Schema use C4::Context->dbh Right now there is no connection between the database handles used by C4::Context::dbh and Koha::Datbase/Schema. This makes it impossible to use transactions in unit tests to temporarily modify the database to test subroutines that take advantage of Koha::Database. This patch fixes that issue. Test Plan: 1) Apply this patch 2) prove -v t/db_dependent/ILSDI_Services.t and prove -v t/db_dependent/Items.t and prove -v t/db_dependent/Circulation_issue.t should all start passing Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28964|0 |1 is obsolete| | --- Comment #14 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 28968 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28968&action=edit Bug 11891: (follow-up) remove custom storage class For now, just rely on the normal DBIx::Class cleanup handler; otherwise, the following warning is displayed in logs: (in cleanup) Can't locate object method "_preserve_foreign_dbh" via package "Koha::Storage" at .../Koha/Storage.pm Using the default DBIC storage class also means that we don't have to manually do things like set the SQL limit dialect; meaning that we don't get the following warning message: DBIx::Class::ResultSet::find(): Your storage class (Koha::Storage) does not set sql_limit_dialect and you have not supplied an explicit limit_dialect in your connection_info. DBIC will attempt to use the GenericSubQ dialect, which works on most databases but can be (and often is) painfully slow. Please file an RT ticket against 'Koha::Storage' . at /home/gmc/koha/C4/Members.pm line 840 Test plan: same as main patch Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28965|0 |1 is obsolete| | --- Comment #15 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 28969 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28969&action=edit Bug 11891: (follow-up) set DBIC storage flags correctly Since we're passing an existing DBI database handle to DBIC, and that handle doesn't have RaiseError set to true by default, don't let DBIC override that -- for now. Test plan: verify that the DB-dependent test suite passes. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master CC| |tomascohen@gmail.com --- Comment #16 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Pushed to master. Thanks Kyle and Galen! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11891 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|9011 | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org