[Koha-devel] [RFC ver2 0/4] use DBIx::Class ORM for database access

Andrew Moore andrew.moore at liblime.com
Fri Oct 31 21:05:23 CET 2008


Here's an update to the proposal I sent last week about starting to use
DBIx::Class as an interface to our database. I've made some updates and
fixed some problems, and think that this is getting close to being ready
to apply to Koha. I'm interested in hearing what you other developers
think of this idea. Perhaps you can help me improve it before we commit
to it.

Changes since last time:

* I'm including a misc/bin/make_schema.pl script that scans our database
and makes a set of perl modules that represent the database. This is
the recommended usage of the module and prevents it from having to scan
the entire database with each usage as it was doing last time. This
program will have to be run each time we change our schema with the
updatedatabase.pl and kohastructure.sql files.

* I fixed a few bugs, like the one that conflicted with our unusual use
of Exporter.

* I included a bunch of test scripts that I left out last time.

As a reminder, here is a brief summary of some of the advantages to
starting to use DBIx::Class:

* This will get us out of the business of writing SQL queries ourselves
and delegate that responsibility to the DBIx::Class modules, which are
more likely to write correct, efficient SQL code than I am.

* This will simplify many spots in or code simply by removing some of
the database maintenance things that we do, like checking for the last
auto_increment value. DBIx::Class knows about that kind of thing and
returns it for you.

* By removing much of our SQL code, we would be removing much of the
code that is specific to MySQL, making it easier to eventually support
other databases.

There are of course drawbacks, among them:

* There may be a perfoamce penalty to using DBIx::Class. I have not
measured anything to see if there is or not.

* DBIx::Class would be a new dependency. DBIx::Class::Schema::Loader
would be a new dependency for develpers, though end-users would not need
to have it installed.


I encourage you to apply these patches, or at least look through them
to see how things would change. I would be interesetd in hearing about
how we could use DBIx::Class differently, other alternatives to it,
or why we should not persue this type of tool at all.

Thanks!
-Andy

Andrew Moore (5):
  DBIx::Class - ACM-DEVELOPMENT: adjusting t/Makefile to find private
    library - DO NOT COMMIT
  DBIx::Class - new C4::Schema object and program to manage
    C4::Schema::* objects
  DBIx::Class - C4::Schema::* objects automatically generated
  DBix::Class - moving C4::ClassSource over to using DBIx::Class
  DBIx::Class - Changes to C4::Members to start using DBIx::Class

 C4/ClassSource.pm                                  |   66 ++--
 C4/Members.pm                                      |   25 +-
 C4/Schema.pm                                       |   68 +++
 C4/Schema/Result/Accountlines.pm                   |   85 ++++
 C4/Schema/Result/Accountoffsets.pm                 |   44 ++
 C4/Schema/Result/ActionLogs.pm                     |   54 +++
 C4/Schema/Result/Alert.pm                          |   28 ++
 C4/Schema/Result/Aqbasket.pm                       |   52 +++
 C4/Schema/Result/Aqbookfund.pm                     |   38 ++
 C4/Schema/Result/Aqbooksellers.pm                  |  249 +++++++++++
 C4/Schema/Result/Aqbudget.pm                       |   47 ++
 C4/Schema/Result/Aqorderbreakdown.pm               |   49 +++
 C4/Schema/Result/Aqorderdelivery.pm                |   44 ++
 C4/Schema/Result/Aqorders.pm                       |  188 ++++++++
 C4/Schema/Result/AuthHeader.pm                     |   58 +++
 C4/Schema/Result/AuthSubfieldStructure.pm          |   67 +++
 C4/Schema/Result/AuthTagStructure.pm               |   44 ++
 C4/Schema/Result/AuthTypes.pm                      |   38 ++
 C4/Schema/Result/AuthorisedValues.pm               |   40 ++
 C4/Schema/Result/Biblio.pm                         |  124 ++++++
 C4/Schema/Result/BiblioFramework.pm                |   24 +
 C4/Schema/Result/Biblioitems.pm                    |  229 ++++++++++
 C4/Schema/Result/BorrowerAttributeTypes.pm         |   46 ++
 C4/Schema/Result/BorrowerAttributes.pm             |   47 ++
 C4/Schema/Result/BorrowerMessagePreferences.pm     |   47 ++
 .../Result/BorrowerMessageTransportPreferences.pm  |   36 ++
 C4/Schema/Result/Borrowers.pm                      |  452 ++++++++++++++++++++
 C4/Schema/Result/BranchBorrowerCircRules.pm        |   36 ++
 C4/Schema/Result/Branchcategories.pm               |   48 ++
 C4/Schema/Result/Branches.pm                       |  137 ++++++
 C4/Schema/Result/Branchrelations.pm                |   34 ++
 C4/Schema/Result/Branchtransfers.pm                |   61 +++
 C4/Schema/Result/Browser.pm                        |   29 ++
 C4/Schema/Result/Categories.pm                     |   95 ++++
 C4/Schema/Result/Cities.pm                         |   31 ++
 C4/Schema/Result/ClassSortRules.pm                 |   37 ++
 C4/Schema/Result/ClassSources.pm                   |   39 ++
 C4/Schema/Result/Currency.pm                       |   43 ++
 C4/Schema/Result/DefaultBorrowerCircRules.pm       |   29 ++
 C4/Schema/Result/DefaultBranchCircRules.pm         |   29 ++
 C4/Schema/Result/DefaultCircRules.pm               |   29 ++
 C4/Schema/Result/Deletedbiblio.pm                  |   84 ++++
 C4/Schema/Result/Deletedbiblioitems.pm             |  219 ++++++++++
 C4/Schema/Result/Deletedborrowers.pm               |  353 +++++++++++++++
 C4/Schema/Result/Deleteditems.pm                   |  206 +++++++++
 C4/Schema/Result/Ethnicity.pm                      |   29 ++
 C4/Schema/Result/HoldFillTargets.pm                |   55 +++
 C4/Schema/Result/ImportBatches.pm                  |   93 ++++
 C4/Schema/Result/ImportBiblios.pm                  |   67 +++
 C4/Schema/Result/ImportItems.pm                    |   54 +++
 C4/Schema/Result/ImportRecordMatches.pm            |   30 ++
 C4/Schema/Result/ImportRecords.pm                  |  115 +++++
 C4/Schema/Result/Issues.pm                         |   66 +++
 C4/Schema/Result/Issuingrules.pm                   |   66 +++
 C4/Schema/Result/Items.pm                          |  250 +++++++++++
 C4/Schema/Result/Itemtypes.pm                      |   60 +++
 C4/Schema/Result/Labels.pm                         |   33 ++
 C4/Schema/Result/LabelsConf.pm                     |   71 +++
 C4/Schema/Result/LabelsProfile.pm                  |   25 ++
 C4/Schema/Result/LabelsTemplates.pm                |   59 +++
 C4/Schema/Result/LanguageDescriptions.pm           |   47 ++
 C4/Schema/Result/LanguageRfc4646ToIso639.pm        |   33 ++
 C4/Schema/Result/LanguageScriptBidi.pm             |   28 ++
 C4/Schema/Result/LanguageScriptMapping.pm          |   33 ++
 C4/Schema/Result/LanguageSubtagRegistry.pm         |   42 ++
 C4/Schema/Result/Letter.pm                         |   43 ++
 C4/Schema/Result/MarcMatchers.pm                   |   50 +++
 C4/Schema/Result/MarcSubfieldStructure.pm          |   89 ++++
 C4/Schema/Result/MarcTagStructure.pm               |   39 ++
 C4/Schema/Result/Matchchecks.pm                    |   43 ++
 C4/Schema/Result/MatcherMatchpoints.pm             |   33 ++
 C4/Schema/Result/MatchpointComponentNorms.pm       |   30 ++
 C4/Schema/Result/MatchpointComponents.pm           |   46 ++
 C4/Schema/Result/Matchpoints.pm                    |   53 +++
 C4/Schema/Result/MessageAttributes.pm              |   37 ++
 C4/Schema/Result/MessageQueue.pm                   |   84 ++++
 C4/Schema/Result/MessageTransportTypes.pm          |   43 ++
 C4/Schema/Result/MessageTransports.pm              |   45 ++
 C4/Schema/Result/Notifys.pm                        |   33 ++
 C4/Schema/Result/Nozebra.pm                        |   32 ++
 C4/Schema/Result/OldIssues.pm                      |   66 +++
 C4/Schema/Result/OldReserves.pm                    |   82 ++++
 C4/Schema/Result/OpacNews.pm                       |   39 ++
 C4/Schema/Result/Overduerules.pm                   |   57 +++
 C4/Schema/Result/Patroncards.pm                    |   38 ++
 C4/Schema/Result/Patronimage.pm                    |   36 ++
 C4/Schema/Result/Permissions.pm                    |   44 ++
 C4/Schema/Result/Printers.pm                       |   36 ++
 C4/Schema/Result/PrintersProfile.pm                |   44 ++
 C4/Schema/Result/RepeatableHolidays.pm             |   49 +++
 C4/Schema/Result/ReportsDictionary.pm              |   59 +++
 C4/Schema/Result/Reserveconstraints.pm             |   34 ++
 C4/Schema/Result/Reserves.pm                       |   87 ++++
 C4/Schema/Result/Reviews.pm                        |   42 ++
 C4/Schema/Result/Roadtype.pm                       |   24 +
 C4/Schema/Result/SavedReports.pm                   |   38 ++
 C4/Schema/Result/SavedSql.pm                       |   73 ++++
 C4/Schema/Result/Serial.pm                         |   62 +++
 C4/Schema/Result/Serialitems.pm                    |   29 ++
 C4/Schema/Result/ServicesThrottle.pm               |   29 ++
 C4/Schema/Result/Sessions.pm                       |   24 +
 C4/Schema/Result/SpecialHolidays.pm                |   36 ++
 C4/Schema/Result/Statistics.pm                     |   71 +++
 C4/Schema/Result/Stopwords.pm                      |   26 ++
 C4/Schema/Result/Subscription.pm                   |  147 +++++++
 C4/Schema/Result/Subscriptionhistory.pm            |   46 ++
 C4/Schema/Result/Subscriptionroutinglist.pm        |   28 ++
 C4/Schema/Result/Suggestions.pm                    |  104 +++++
 C4/Schema/Result/Systempreferences.pm              |   50 +++
 C4/Schema/Result/Tags.pm                           |   24 +
 C4/Schema/Result/TagsAll.pm                        |   42 ++
 C4/Schema/Result/TagsApproval.pm                   |   45 ++
 C4/Schema/Result/TagsIndex.pm                      |   32 ++
 C4/Schema/Result/TmpHoldsqueue.pm                  |   99 +++++
 C4/Schema/Result/UserPermissions.pm                |   40 ++
 C4/Schema/Result/Userflags.pm                      |   43 ++
 C4/Schema/Result/Virtualshelfcontents.pm           |   42 ++
 C4/Schema/Result/Virtualshelves.pm                 |   57 +++
 C4/Schema/Result/Z3950servers.pm                   |  100 +++++
 C4/Schema/Result/Zebraqueue.pm                     |   37 ++
 misc/bin/make_schema.pl                            |   70 +++
 t/Makefile                                         |    2 +-
 t/lib/KohaTest/ClassSource.pm                      |   34 ++
 t/lib/KohaTest/ClassSource/ClassSource.pm          |   56 +++
 124 files changed, 7954 insertions(+), 53 deletions(-)
 create mode 100644 C4/Schema.pm
 create mode 100644 C4/Schema/Result/Accountlines.pm
 create mode 100644 C4/Schema/Result/Accountoffsets.pm
 create mode 100644 C4/Schema/Result/ActionLogs.pm
 create mode 100644 C4/Schema/Result/Alert.pm
 create mode 100644 C4/Schema/Result/Aqbasket.pm
 create mode 100644 C4/Schema/Result/Aqbookfund.pm
 create mode 100644 C4/Schema/Result/Aqbooksellers.pm
 create mode 100644 C4/Schema/Result/Aqbudget.pm
 create mode 100644 C4/Schema/Result/Aqorderbreakdown.pm
 create mode 100644 C4/Schema/Result/Aqorderdelivery.pm
 create mode 100644 C4/Schema/Result/Aqorders.pm
 create mode 100644 C4/Schema/Result/AuthHeader.pm
 create mode 100644 C4/Schema/Result/AuthSubfieldStructure.pm
 create mode 100644 C4/Schema/Result/AuthTagStructure.pm
 create mode 100644 C4/Schema/Result/AuthTypes.pm
 create mode 100644 C4/Schema/Result/AuthorisedValues.pm
 create mode 100644 C4/Schema/Result/Biblio.pm
 create mode 100644 C4/Schema/Result/BiblioFramework.pm
 create mode 100644 C4/Schema/Result/Biblioitems.pm
 create mode 100644 C4/Schema/Result/BorrowerAttributeTypes.pm
 create mode 100644 C4/Schema/Result/BorrowerAttributes.pm
 create mode 100644 C4/Schema/Result/BorrowerMessagePreferences.pm
 create mode 100644 C4/Schema/Result/BorrowerMessageTransportPreferences.pm
 create mode 100644 C4/Schema/Result/Borrowers.pm
 create mode 100644 C4/Schema/Result/BranchBorrowerCircRules.pm
 create mode 100644 C4/Schema/Result/Branchcategories.pm
 create mode 100644 C4/Schema/Result/Branches.pm
 create mode 100644 C4/Schema/Result/Branchrelations.pm
 create mode 100644 C4/Schema/Result/Branchtransfers.pm
 create mode 100644 C4/Schema/Result/Browser.pm
 create mode 100644 C4/Schema/Result/Categories.pm
 create mode 100644 C4/Schema/Result/Cities.pm
 create mode 100644 C4/Schema/Result/ClassSortRules.pm
 create mode 100644 C4/Schema/Result/ClassSources.pm
 create mode 100644 C4/Schema/Result/Currency.pm
 create mode 100644 C4/Schema/Result/DefaultBorrowerCircRules.pm
 create mode 100644 C4/Schema/Result/DefaultBranchCircRules.pm
 create mode 100644 C4/Schema/Result/DefaultCircRules.pm
 create mode 100644 C4/Schema/Result/Deletedbiblio.pm
 create mode 100644 C4/Schema/Result/Deletedbiblioitems.pm
 create mode 100644 C4/Schema/Result/Deletedborrowers.pm
 create mode 100644 C4/Schema/Result/Deleteditems.pm
 create mode 100644 C4/Schema/Result/Ethnicity.pm
 create mode 100644 C4/Schema/Result/HoldFillTargets.pm
 create mode 100644 C4/Schema/Result/ImportBatches.pm
 create mode 100644 C4/Schema/Result/ImportBiblios.pm
 create mode 100644 C4/Schema/Result/ImportItems.pm
 create mode 100644 C4/Schema/Result/ImportRecordMatches.pm
 create mode 100644 C4/Schema/Result/ImportRecords.pm
 create mode 100644 C4/Schema/Result/Issues.pm
 create mode 100644 C4/Schema/Result/Issuingrules.pm
 create mode 100644 C4/Schema/Result/Items.pm
 create mode 100644 C4/Schema/Result/Itemtypes.pm
 create mode 100644 C4/Schema/Result/Labels.pm
 create mode 100644 C4/Schema/Result/LabelsConf.pm
 create mode 100644 C4/Schema/Result/LabelsProfile.pm
 create mode 100644 C4/Schema/Result/LabelsTemplates.pm
 create mode 100644 C4/Schema/Result/LanguageDescriptions.pm
 create mode 100644 C4/Schema/Result/LanguageRfc4646ToIso639.pm
 create mode 100644 C4/Schema/Result/LanguageScriptBidi.pm
 create mode 100644 C4/Schema/Result/LanguageScriptMapping.pm
 create mode 100644 C4/Schema/Result/LanguageSubtagRegistry.pm
 create mode 100644 C4/Schema/Result/Letter.pm
 create mode 100644 C4/Schema/Result/MarcMatchers.pm
 create mode 100644 C4/Schema/Result/MarcSubfieldStructure.pm
 create mode 100644 C4/Schema/Result/MarcTagStructure.pm
 create mode 100644 C4/Schema/Result/Matchchecks.pm
 create mode 100644 C4/Schema/Result/MatcherMatchpoints.pm
 create mode 100644 C4/Schema/Result/MatchpointComponentNorms.pm
 create mode 100644 C4/Schema/Result/MatchpointComponents.pm
 create mode 100644 C4/Schema/Result/Matchpoints.pm
 create mode 100644 C4/Schema/Result/MessageAttributes.pm
 create mode 100644 C4/Schema/Result/MessageQueue.pm
 create mode 100644 C4/Schema/Result/MessageTransportTypes.pm
 create mode 100644 C4/Schema/Result/MessageTransports.pm
 create mode 100644 C4/Schema/Result/Notifys.pm
 create mode 100644 C4/Schema/Result/Nozebra.pm
 create mode 100644 C4/Schema/Result/OldIssues.pm
 create mode 100644 C4/Schema/Result/OldReserves.pm
 create mode 100644 C4/Schema/Result/OpacNews.pm
 create mode 100644 C4/Schema/Result/Overduerules.pm
 create mode 100644 C4/Schema/Result/Patroncards.pm
 create mode 100644 C4/Schema/Result/Patronimage.pm
 create mode 100644 C4/Schema/Result/Permissions.pm
 create mode 100644 C4/Schema/Result/Printers.pm
 create mode 100644 C4/Schema/Result/PrintersProfile.pm
 create mode 100644 C4/Schema/Result/RepeatableHolidays.pm
 create mode 100644 C4/Schema/Result/ReportsDictionary.pm
 create mode 100644 C4/Schema/Result/Reserveconstraints.pm
 create mode 100644 C4/Schema/Result/Reserves.pm
 create mode 100644 C4/Schema/Result/Reviews.pm
 create mode 100644 C4/Schema/Result/Roadtype.pm
 create mode 100644 C4/Schema/Result/SavedReports.pm
 create mode 100644 C4/Schema/Result/SavedSql.pm
 create mode 100644 C4/Schema/Result/Serial.pm
 create mode 100644 C4/Schema/Result/Serialitems.pm
 create mode 100644 C4/Schema/Result/ServicesThrottle.pm
 create mode 100644 C4/Schema/Result/Sessions.pm
 create mode 100644 C4/Schema/Result/SpecialHolidays.pm
 create mode 100644 C4/Schema/Result/Statistics.pm
 create mode 100644 C4/Schema/Result/Stopwords.pm
 create mode 100644 C4/Schema/Result/Subscription.pm
 create mode 100644 C4/Schema/Result/Subscriptionhistory.pm
 create mode 100644 C4/Schema/Result/Subscriptionroutinglist.pm
 create mode 100644 C4/Schema/Result/Suggestions.pm
 create mode 100644 C4/Schema/Result/Systempreferences.pm
 create mode 100644 C4/Schema/Result/Tags.pm
 create mode 100644 C4/Schema/Result/TagsAll.pm
 create mode 100644 C4/Schema/Result/TagsApproval.pm
 create mode 100644 C4/Schema/Result/TagsIndex.pm
 create mode 100644 C4/Schema/Result/TmpHoldsqueue.pm
 create mode 100644 C4/Schema/Result/UserPermissions.pm
 create mode 100644 C4/Schema/Result/Userflags.pm
 create mode 100644 C4/Schema/Result/Virtualshelfcontents.pm
 create mode 100644 C4/Schema/Result/Virtualshelves.pm
 create mode 100644 C4/Schema/Result/Z3950servers.pm
 create mode 100644 C4/Schema/Result/Zebraqueue.pm
 create mode 100755 misc/bin/make_schema.pl
 create mode 100644 t/lib/KohaTest/ClassSource.pm
 create mode 100644 t/lib/KohaTest/ClassSource/ClassSource.pm




More information about the Koha-devel mailing list