[Dbix-class] RootClass DBIx::ContextualFetch

Peter Rabbitson rabbit+dbic at rabbit.us
Sat Sep 26 15:54:09 GMT 2015


On 09/26/2015 04:13 PM, Bill Moseley wrote:
> I have an old app that uses DBI directly with Postgresql.   I want to
> add in support for DBIx::Class into the same app.  I don't want to
> double the number of database connections so would like to replace the
> method that returns a $dbh in the old app with:
>
>     $schema->storage->dbh;  # [1]
>
>
> The issue is the old app uses DBI with a RootClass of
> DBIx::ContextualFetch
> <http://search.cpan.org/dist/DBIx-ContextualFetch/lib/DBIx/ContextualFetch.pm#EXTENSIONS>.
>
> I see that DBIx::Class::CDBICompat::ImaDBI uses DBIx::ContextualFetch.
>
> Is there any problem with setting the RootClass as DBIx::ContextualFetch
> and running DBIC normally?

I don't think there will be, but this has not been tested either.

>
> [1] Actually, I'd probably calll $storage->_get_dbh to reduced the
> number of pings.

I would wrap the entire app call as:

  $storage->dbh_do(sub { app goes here using $_[1] } )

This way you are both protected from spurious pings, and from oddball 
disconnects (as long as the app is omnipotent).




More information about the DBIx-Class mailing list