Re: [RDBO] Still fighting with transactions

2007-08-15 Thread John Siracusa
On 8/15/07 10:08 PM, Graham Barr wrote: > On Aug 15, 2007, at 7:56 PM, John Siracusa wrote: >> The only dbh attributes that get set in init_dbh() after the >> DBI->connect() call are the ones that don't (apparently?) work if >> passed as connect options. > > You are right, sorry. > > It is DBI->c

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Graham Barr
On Aug 15, 2007, at 7:56 PM, John Siracusa wrote: > On 8/15/07, Graham Barr <[EMAIL PROTECTED]> wrote: >> On Wed, August 15, 2007 7:54 am, John Siracusa wrote: >>> The real question is, why is some_helper_that_uses_db() causing a >>> rollback? >>> Turn on DBI->trace(1) to be sure it actually is

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread John Siracusa
On 8/15/07, Graham Barr <[EMAIL PROTECTED]> wrote: > On Wed, August 15, 2007 7:54 am, John Siracusa wrote: >> The real question is, why is some_helper_that_uses_db() causing a rollback? >> Turn on DBI->trace(1) to be sure it actually is, and maybe try to create a >> small test case. > > the problem

Re: [RDBO] guessing method name for many-to-many counting method.

2007-08-15 Thread John Siracusa
On 8/15/07, George Hartzell <[EMAIL PROTECTED]> wrote: > I'd like to get a count of the number of colors associated with a > widget. I know that I could just fetch them and count them, but I > thought that the relationship might provide a count method and now I'm > distracted by the generic questi

[RDBO] guessing method name for many-to-many counting method.

2007-08-15 Thread George Hartzell
I have a many-to-many relationship between a pair of tables, using a mapping table, that Rose::DB::Object::Loader sets up properly for me. I can use (e.g.) $widget->add_colors($a_color) to add colors to the widget, so I think it's working right. I'd like to get a count of the number of colors as

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Tim Bunce
On Wed, Aug 15, 2007 at 01:06:01PM -0500, Graham Barr wrote: > > Rose::DB does not know that the $dbh it get back from connect is not a > newly connected handle. As a result is still goes ahead and calls init_dbh > which will set all the dbh attributes to the defaults. The standard approach I rec

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Tim Bunce
On Wed, Aug 15, 2007 at 01:06:01PM -0500, Graham Barr wrote: > > in Rose::DB AutoCommit has a default of 1. In my case that is the default > I want. But when Rose::DB->new is called and there is currently an active > transation, the code in init_dbh will reset AutoCommit to 0. Perhaps connect_cac

Re: [RDBO] help specifying a default datetime with SQLite and RDBO::Loader

2007-08-15 Thread George Hartzell
John Siracusa writes: > On 8/14/07, George Hartzell <[EMAIL PROTECTED]> wrote: > > The default value of "now" does work when used in the RDBO perl > > module. The problem is that since I'm using RDBO::Loader, the only > > way to get that value in there is to use it in the SQL, where it > > do

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Perrin Harkins
On 8/15/07, Graham Barr <[EMAIL PROTECTED]> wrote: > So either init_dbh needs to be able to detect that the $dbh it gets is a > reuse of an existing connection, or Rose::DB->new needs to return the same > object for all calls for the same connection. Even if init_dbh is changed, I think Apache::DB

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Graham Barr
On Wed, August 15, 2007 7:54 am, John Siracusa wrote: > The real question is, why is some_helper_that_uses_db() causing a > rollback? > Turn on DBI->trace(1) to be sure it actually is, and maybe try to create a > small test case. the problem is in init_dbh. Rose::DB does not know that the $dbh it

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Michael Lackhoff
On 15.08.2007 18:47 Perrin Harkins wrote: > I have a guess. Looking at the new code in Apache::DBI, I see that it > now tries to reset the state of the $dbh every time you call > connect(). This probably breaks the begin_work() state. > > I'm not sure why this was added, since it seems like thi

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Perrin Harkins
On 8/15/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote: > Well, I didn't switch AutoCommit on or off and I didn't do a rollback > myself, so the question remains why the default configuration with > Apache::DBI and init_db(MyApp::DB->new) does a rollback when the > database is accessed from a new d

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread John Siracusa
On 8/15/07 3:11 AM, Michael Lackhoff wrote: > On 14.08.2007 22:43 John Siracusa wrote: >> Assuming your have AutoCommit turned off, that's why $obj was not >> saved. The rollback rolled back everything done since the last >> begin_work(). > > Well, I didn't switch AutoCommit on or off Was it on

Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Michael Lackhoff
On 14.08.2007 22:43 John Siracusa wrote: > On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote: >> On 14.08.2007 20:34 John Siracusa wrote: >>> On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote: $db->begin_work; my $obj = Products->new(db => $db); ... $obj->save; s