bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

Ability to replace DBI with a module which subclasses DBI #26

Open mjegh opened 12 years ago

mjegh commented 12 years ago

I'd really like to Dancer::Plugin::Database to call DBIx::Log4perl->connect instead of DBI->connect. DBIx::Log4perl subclasses DBI so it should be fairly straight forward if D::P::D had a config option for it.

bigpresh commented 12 years ago

This seemed dead easy to start with - a new optional param, dbi_class or something, and have the connection code use $class->connect instead of DBI->connect.

However, where it gets interesting is that the DB handle is then re-blessed into Dancer::Plugin::Database::Handle which subclasses DBI::db. For this to work, the code would presumably need to call $class->connect, then see what kind of object it got back (DBI::db, DBIx::Log4perl::db, ...) then arrange for the D::P::D::Handle to subclass that type of object at runtime. That could make things more complex.

I shall have a further think on this as soon as I have a moment - suggestions welcome of course :)