bigpresh/Dancer-Plugin-Database

Ability to replace DBI with a module which subclasses DBI

mjegh opened this issue · 1 comments

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.

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 :)