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


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to