RootClass DBIx::ContextualFetch

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RootClass DBIx::ContextualFetch

Bill Moseley
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.

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?


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

--
Bill Moseley
[hidden email]

_______________________________________________
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@...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RootClass DBIx::ContextualFetch

Bill Moseley


On Sat, Sep 26, 2015 at 8:54 AM, Peter Rabbitson <[hidden email]> wrote:
 
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.

Thanks, Peter.


I would wrap the entire app call as:

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

I looked at that, but I guess I'm not clear how to use accomplish it since there's hundreds (if not thousands) of existing individual direct DBI calls in the app.

 
Thanks,

--
Bill Moseley
[hidden email]

_______________________________________________
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@...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RootClass DBIx::ContextualFetch

Will Crawford
I'd create some sort of proxy object that stores a ref to $schema and does the ->dbh_do magic behind the scenes whenever you call a method on it ...

On 26 September 2015 at 18:23, Bill Moseley <[hidden email]> wrote:


On Sat, Sep 26, 2015 at 8:54 AM, Peter Rabbitson <[hidden email]> wrote:
 
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.

Thanks, Peter.


I would wrap the entire app call as:

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

I looked at that, but I guess I'm not clear how to use accomplish it since there's hundreds (if not thousands) of existing individual direct DBI calls in the app.

 
Thanks,

--
Bill Moseley
[hidden email]

_______________________________________________
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@...


_______________________________________________
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@...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RootClass DBIx::ContextualFetch

Bill Moseley


On Mon, Sep 28, 2015 at 2:45 AM, Will Crawford <[hidden email]> wrote:
I'd create some sort of proxy object that stores a ref to $schema and does the ->dbh_do magic behind the scenes whenever you call a method on it ...

Frankly, I'm afraid to touch the legacy code much.    The legacy code has its own DBI subclass that holds real DBI $dbh handles for master and slaves database servers and tracks master or slave in a global.   Transactions are started automatically and the app code where a commit is called could be even in a different module than where the transaction was started.   Nasty stuff.

 

On 26 September 2015 at 18:23, Bill Moseley <[hidden email]> wrote:


On Sat, Sep 26, 2015 at 8:54 AM, Peter Rabbitson <[hidden email]> wrote:
 
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.

Thanks, Peter.


I would wrap the entire app call as:

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

I looked at that, but I guess I'm not clear how to use accomplish it since there's hundreds (if not thousands) of existing individual direct DBI calls in the app.

 
Thanks,

--
Bill Moseley
[hidden email]

_______________________________________________
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@...


_______________________________________________
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@...



--
Bill Moseley
[hidden email]

_______________________________________________
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@...
Loading...