Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 52681
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: fred.steinberg [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.08115
Fixed in: 0.08121



Subject: Cookbook doc patch
Might be helpful in "Automatically creating related objects" to have an example w/transaction, since it requires $self->next::can . E.g. add If you want to wrap the inserts in a transaction, you'll need to get a ref to the overloaded method and pass that along: sub insert { my ( $self, @args ) = @_; my $artist_insert = $self->next::can; my $insert_artist_and_cds = sub { $artist_insert->($self, @args); $self->cds->new({})->fill_from_artist($self)->insert; } eval { $self->result_source->schema->txn_do ($insert_artist_and_cds); }; if ($@) { deal_with_failed_transaction(); } return $self; }
Subject: cookbook.patch
--- Cookbook.pod 2009-12-11 13:01:53.000000000 -0500 +++ Cookbook.pod.new 2009-12-11 13:13:03.000000000 -0500 @@ -1827,6 +1827,30 @@ where C<fill_from_artist> is a method you specify in C<CD> which sets values in C<CD> based on the data in the C<Artist> object you pass in. +If you want to wrap the inserts in a transaction, you'll need to get a +ref to the overloaded method and pass that along: + + sub insert { + my ( $self, @args ) = @_; + + my $artist_insert = $self->next::can; + + my $insert_artist_and_cds = sub { + $artist_insert->($self, @args); + $self->cds->new({})->fill_from_artist($self)->insert; + } + + eval { + $self->result_source->schema->txn_do ($insert_artist_and_cds); + }; + if ($@) { + deal_with_failed_transaction(); + } + + return $self; + } + + =head2 Wrapping/overloading a column accessor B<Problem:>
Thank you for the patch, applied with modifications (same spirit): http://dev.catalyst.perl.org/svnweb/bast/revision?rev=8464 Note that using txn_do in *internal* code is a bad idea, as it will retry on errors, which often is not desirable. The ScopeGuard is the correct "dumb" way to have inline transactions.
Subject: Re: [rt.cpan.org #52681] Cookbook doc patch
Date: Thu, 28 Jan 2010 10:11:31 -0500
To: bug-DBIx-Class [...] rt.cpan.org
From: Fred Steinberg <fred.steinberg [...] gmail.com>
Ah, very nice! I hadn't seen TxnScopeGuard before. What do you think about adding a brief mention in the main "Transactions" section in the Cookbook? (Maybe a new =head2 after 'Nested transactions and auto-savepoints') FYI, I also wasn't aware of the auto-retry on dropped connections (that's _only_ for dropped db connection, correct? That's implied but not quite explicitly stated here: http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/Storage.pm#txn_do .) Thanks for all your work! -Fred On Thu, Jan 28, 2010 at 6:27 AM, Peter Rabbitson via RT <bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=52681 > > > Thank you for the patch, applied with modifications (same spirit): > http://dev.catalyst.perl.org/svnweb/bast/revision?rev=8464 > > Note that using txn_do in *internal* code is a bad idea, as it will > retry on errors, which often is not desirable. The ScopeGuard is the > correct "dumb" way to have inline transactions. >
On Thu Jan 28 10:12:54 2010, freds wrote: Show quoted text
> Ah, very nice! I hadn't seen TxnScopeGuard before. What do you think > about adding a brief mention in the main "Transactions" section in the > Cookbook? (Maybe a new =head2 after 'Nested transactions and > auto-savepoints') > > FYI, I also wasn't aware of the auto-retry on dropped connections > (that's _only_ for dropped db connection, correct? That's implied but > not quite explicitly stated here: > http://search.cpan.org/~frew/DBIx-Class- > 0.08115/lib/DBIx/Class/Storage.pm#txn_do > .)
I wouldn't mind such doc improvements at all. Please submit a draft-diff of what you think should be said where. Then I can edit them for correctness just like I did with your initial patch. Cheers!
Subject: Re: [rt.cpan.org #52681] Cookbook doc patch
Date: Tue, 2 Feb 2010 11:20:27 -0500
To: bug-DBIx-Class [...] rt.cpan.org
From: Fred Steinberg <fred.steinberg [...] gmail.com>
Sure, sounds good. I'll try to get that to you later this week. -Fred PS If you'd rather I use the RT web interface instead of email, please let me know. On Sat, Jan 30, 2010 at 5:58 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=52681 > > > On Thu Jan 28 10:12:54 2010, freds wrote:
> > Ah, very nice! I hadn't seen TxnScopeGuard before. What do you think > > about adding a brief mention in the main "Transactions" section in the > > Cookbook? (Maybe a new =head2 after 'Nested transactions and > > auto-savepoints') > > > > FYI, I also wasn't aware of the auto-retry on dropped connections > > (that's _only_ for dropped db connection, correct? That's implied but > > not quite explicitly stated here: > > http://search.cpan.org/~frew/DBIx-Class- > > 0.08115/lib/DBIx/Class/Storage.pm#txn_do > > .)
> > I wouldn't mind such doc improvements at all. Please submit a draft-diff > of what you think should be said where. Then I can edit them for > correctness just like I did with your initial patch. Cheers! >
On Tue Feb 02 11:21:51 2010, freds wrote: Show quoted text
> Sure, sounds good. I'll try to get that to you later this week. > -Fred > > PS If you'd rather I use the RT web interface instead of email, please let > me know. > > > On Sat, Jan 30, 2010 at 5:58 AM, Peter Rabbitson via RT < > bug-DBIx-Class@rt.cpan.org> wrote: >
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=52681 > > > > > On Thu Jan 28 10:12:54 2010, freds wrote:
> > > Ah, very nice! I hadn't seen TxnScopeGuard before. What do you think > > > about adding a brief mention in the main "Transactions" section in the > > > Cookbook? (Maybe a new =head2 after 'Nested transactions and > > > auto-savepoints') > > > > > > FYI, I also wasn't aware of the auto-retry on dropped connections > > > (that's _only_ for dropped db connection, correct? That's implied but > > > not quite explicitly stated here: > > > http://search.cpan.org/~frew/DBIx-Class- > > > 0.08115/lib/DBIx/Class/Storage.pm#txn_do > > > .)
> > > > I wouldn't mind such doc improvements at all. Please submit a draft-diff > > of what you think should be said where. Then I can edit them for > > correctness just like I did with your initial patch. Cheers! > >
Any news on that docpatch? Changing status to stalled for the time being.
Subject: Re: [rt.cpan.org #52681] Cookbook doc patch
Date: Mon, 8 Mar 2010 17:56:13 -0500
To: bug-DBIx-Class [...] rt.cpan.org
From: Fred Steinberg <fred.steinberg [...] gmail.com>
On Sat, Mar 6, 2010 at 6:32 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=52681 > > > On Tue Feb 02 11:21:51 2010, freds wrote:
> > Sure, sounds good. I'll try to get that to you later this week. > > -Fred > > > > PS If you'd rather I use the RT web interface instead of email, please
> let
> > me know. > >
> > Any news on that docpatch? Changing status to stalled for the time being. >
Whoops - sorry about that! Here's a simple change; diff against r8464 Thanks for the reminder; -Fred PS Also a typo fix in there; 'controll' --> 'control'

Message body is not shown because sender requested not to inline it.

On Mon Mar 08 17:57:37 2010, freds wrote: Show quoted text
> On Sat, Mar 6, 2010 at 6:32 AM, Peter Rabbitson via RT < > bug-DBIx-Class@rt.cpan.org> wrote: >
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=52681 > > > > > On Tue Feb 02 11:21:51 2010, freds wrote:
> > > Sure, sounds good. I'll try to get that to you later this week. > > > -Fred > > > > > > PS If you'd rather I use the RT web interface instead of email, please
> > let
> > > me know. > > >
> > > > Any news on that docpatch? Changing status to stalled for the time
being. Show quoted text
> >
> > > Whoops - sorry about that! Here's a simple change; diff against r8464 > Thanks for the reminder; > -Fred > > PS Also a typo fix in there; 'controll' --> 'control'
Committed with slight changes: http://dev.catalystframework.org/svnweb/bast/revision?rev=8953
Subject: Re: [rt.cpan.org #52681] Cookbook doc patch
Date: Wed, 10 Mar 2010 09:11:18 -0500
To: bug-DBIx-Class [...] rt.cpan.org
From: Fred Steinberg <fred.steinberg [...] gmail.com>
On Wed, Mar 10, 2010 at 3:35 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
Nice, thanks Peter. I spotted one typo in the new stuff, in line #364; this: I will not (and really can not) retry... should be It will not (and really can not) retry... -Fred
On Wed Mar 10 09:14:56 2010, freds wrote: Show quoted text
> On Wed, Mar 10, 2010 at 3:35 AM, Peter Rabbitson via RT < > bug-DBIx-Class@rt.cpan.org> wrote: > > > > Nice, thanks Peter. I spotted one typo in the new stuff, in line #364;
this: Show quoted text
> > I will not (and really can not) retry... > > should be > > It will not (and really can not) retry... > > -Fred
NO, I WILL NOT RETRY!!!! http://dev.catalystframework.org/svnweb/bast/revision?rev=8961 Thanks for spotting :)
DBIC 0.08121 shipped containing a fix for this bug.