Grokbase
Topics Posts Groups | in
x
[ help ]

Zbigniew Lukasiak (z...@gmail.com)

Profile | Posts (147)

User Information

Display Name:Zbigniew Lukasiak
Partial Email Address:z...@gmail.com
Posts:
147 total
11 in Catalyst Framework Development
46 in Catalyst Framework
4 in catalyst@lists.scsys.co.uk
51 in DBIx::Class
1 in dbix-class@lists.scsys.co.uk
6 in HTML::FormFu
28 in HTML::FormFu

5 Most Recent

All Posts
1) Zbigniew Lukasiak [Catalyst] Success stories please
| +1 vote
Nearly all the comments talk about Catalyst - looks like it is the number one player here - I don't...
catalyst@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Mon, Oct 6, 2008 at 1:01 AM, J. Shirley <jshirley@gmail.com> wrote:
>
> Andy apparently just wanted to start a flamewar. This "article" is
> idiotic, the reasons more so. I'm disappointed in perlbuzz in general
> as it now holds the same amount of respect as getting my news from The
> National Inquirer.

Nearly all the comments talk about Catalyst - looks like it is the
number one player here - I don't see any reason to be defensive.
2) Zbigniew Lukasiak [Dbix-class] Re: DBIx::Class::ResultSet::RecursiveUpdate - announcement and RFC
| +1 vote
I am curious about those different behaviours - what do you have on mind? Ad PK - it is in the...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Sun, Oct 5, 2008 at 12:22 PM, Matt S Trout <dbix-class@trout.me.uk> wrote:
> On Thu, Oct 02, 2008 at 08:18:59AM +0100, Carl Franks wrote:
>> 2008/10/2 Zbigniew Lukasiak <zzbbyy@gmail.com>:
>> > On Thu, Oct 2, 2008 at 2:40 AM, Matt S Trout <dbix-class@trout.me.uk> wrote:
>> >> On Wed, Oct 01, 2008 at 09:38:07AM +0200, Zbigniew Lukasiak wrote:
>> >>> The example that I am mostly concerned with is:
>> >>>
>> >>> $cd_rs->recursive_update( { title => 'New Title', artist => { name =>
>> >>> 'New Name' } } )
>> >>>
>> >>> Now when traversing the relation from cd to the artist I get the
>> >>> artist resultset with the PK constrained in the ->{cond}. There is
>> >>> just one artist that the cd 'belongs_to' - and that artist should be
>> >>> updated. But there is no PK passed in the parameters - so if we just
>> >>> look at the parameters we would conclude that this would require a
>> >>> ->create call.
>> >>
>> >> Ah, because the artist is about to be changed?
>> >>
>> >> In that case you should create the artist separately and then assign it
>> >> I think, which again avoids the problem.
>> >>
>> >
>> > Perhaps I did not explain it enough - I want that call to result in an
>> > update not a create. An update to the only artist that 'belongs_to'
>> > the cd.
>>
>> ( /me steps into a minefield )
>>
>> I would suggest that if it's an update, you should already have the
>> artist PK - keep ahold of it when you're initially getting the vales
>> from the DB.
>>
>> Then, when you're doing the update, verify the PK hasn't changed (or
>> maybe allow it to be configured to allow rel ID changes).
>>
>> I know FormFu doesn't do that, it can just follow the relationship
>> name, so you don't need a hidden field for the related PK - but I feel
>> it's more flexible to handle traversing the relationships ourselves,
>> rather than using a core DBIC recursive-update.
>
> Especially given there are probably multiple different behaviours you'll
> want in different situations.

I am curious about those different behaviours - what do you have on mind?

Ad PK - it is in the relationship - this is a 'belongs_to' after all -
I don't want to require the user of the libarary to have to worry
about it.

Cheers,
Zbigniew
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/
3) Zbigniew Lukasiak [Dbix-class] Re: DBIx::Class::ResultSet::RecursiveUpdate - announcement and RFC
| +1 vote
Perhaps I did not explain it enough - I want that call to result in an update not a create. An...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu, Oct 2, 2008 at 2:40 AM, Matt S Trout <dbix-class@trout.me.uk> wrote:
> On Wed, Oct 01, 2008 at 09:38:07AM +0200, Zbigniew Lukasiak wrote:
>> On Wed, Oct 1, 2008 at 3:17 AM, Matt S Trout <dbix-class@trout.me.uk> wrote:
>> > On Tue, Sep 30, 2008 at 02:39:00PM +0200, Zbigniew Lukasiak wrote:
>> >> On Tue, Sep 30, 2008 at 2:20 PM, Matt S Trout <dbix-class@trout.me.uk> wrote:
>> >> > Well, yes. If you have an auto-increment PK and you don't have a value for
>> >> > it, then
>> >> >
>> >> > (1) there's no form field in the first place, so that's not an issue
>> >> >
>> >> > (2) you know you can't possibly find anything, so you wouldn't call
>> >> > update_or_create, you'd just call create
>> >> >
>> >> > I presume this is what Oliver's doing, which is why his code works.
>> >> >
>> >> > Nothing tricky at all.
>> >>
>> >> This method assumes that you don't get the PK in the ResultSet in the
>> >> internal conditions. I is ok if you have the full controll over the
>> >> ResultSet - but if you do admit this possibility (for example when you
>> >> traverse a belongs_to relation, or if you use RestrictedWithObject) -
>> >> then you would have to inspect it o check what part of the PK is there
>> >> to decide if you should go directly to ->create. Since currently
>> >> there is no easy and sound way of doing this inspection (and for some,
>> >> rather convoluted - I admit, cases it is impossible - that is it is
>> >> undecidable - i.e. cannot be solved by an algorithm) - this makes this
>> >> method unsuitable for my purposes.
>> >
>> > I don't see that this would ever happen with an auto-inc PK though.
>> >
>> > And if it's a unique key, the behaviour is rather different.
>> >
>> > Basically, I've not yet seen a real world example where this situation
>> > actually comes up, and I can't think of a contrived one that doesn't come
>> > into the category of "your design is broken".
>> >
>> > So it's so far a problem in theory but not in practice - can you provide
>> > a real example of this situation?
>>
>> The example that I am mostly concerned with is:
>>
>> $cd_rs->recursive_update( { title => 'New Title', artist => { name =>
>> 'New Name' } } )
>>
>> Now when traversing the relation from cd to the artist I get the
>> artist resultset with the PK constrained in the ->{cond}. There is
>> just one artist that the cd 'belongs_to' - and that artist should be
>> updated. But there is no PK passed in the parameters - so if we just
>> look at the parameters we would conclude that this would require a
>> ->create call.
>
> Ah, because the artist is about to be changed?
>
> In that case you should create the artist separately and then assign it
> I think, which again avoids the problem.
>

Perhaps I did not explain it enough - I want that call to result in an
update not a create.  An update to the only artist that 'belongs_to'
the cd.
4) Zbigniew Lukasiak [Dbix-class] install test failures
| +1 vote
It is rather old. I don't know if it is worth the trouble to check that - better load the latest...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Wed, Oct 1, 2008 at 4:33 PM, Dave Howorth <dhoworth@mrc-lmb.cam.ac.uk> wrote:
> I just tried to install DBIx-Class-0.08099_04 and have three failing

It is rather old.  I don't know if it is worth the trouble to check
that - better load the latest svn version from:
http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk

Cheers,
Zbigniew
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/
5) Zbigniew Lukasiak [Dbix-class] Re: DBIx::Class::ResultSet::RecursiveUpdate - announcement and RFC
| +1 vote
The example that I am mostly concerned with is: $cd_rs->recursive_update( { title => 'New Title',...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Wed, Oct 1, 2008 at 3:17 AM, Matt S Trout <dbix-class@trout.me.uk> wrote:
> On Tue, Sep 30, 2008 at 02:39:00PM +0200, Zbigniew Lukasiak wrote:
>> On Tue, Sep 30, 2008 at 2:20 PM, Matt S Trout <dbix-class@trout.me.uk> wrote:
>> > On Tue, Sep 30, 2008 at 09:28:50AM +0200, Zbigniew Lukasiak wrote:
>> >> The tricky part is when you load data from the form into the new row.
>> >> You need to delete the pk from it - because otherwise at
>> >> update_or_insert time it would issue an insert with pk = NULL - and
>> >> this will fail in Pg (for example). The point is that you cannot feed
>> >> the same data to the find and to the insert calls - but
>> >> update_or_create does that - and why it does not have much choice is
>> >> another very long story.
>> >
>> > Well, yes. If you have an auto-increment PK and you don't have a value for
>> > it, then
>> >
>> > (1) there's no form field in the first place, so that's not an issue
>> >
>> > (2) you know you can't possibly find anything, so you wouldn't call
>> > update_or_create, you'd just call create
>> >
>> > I presume this is what Oliver's doing, which is why his code works.
>> >
>> > Nothing tricky at all.
>>
>> This method assumes that you don't get the PK in the ResultSet in the
>> internal conditions. I is ok if you have the full controll over the
>> ResultSet - but if you do admit this possibility (for example when you
>> traverse a belongs_to relation, or if you use RestrictedWithObject) -
>> then you would have to inspect it o check what part of the PK is there
>> to decide if you should go directly to ->create. Since currently
>> there is no easy and sound way of doing this inspection (and for some,
>> rather convoluted - I admit, cases it is impossible - that is it is
>> undecidable - i.e. cannot be solved by an algorithm) - this makes this
>> method unsuitable for my purposes.
>
> I don't see that this would ever happen with an auto-inc PK though.
>
> And if it's a unique key, the behaviour is rather different.
>
> Basically, I've not yet seen a real world example where this situation
> actually comes up, and I can't think of a contrived one that doesn't come
> into the category of "your design is broken".
>
> So it's so far a problem in theory but not in practice - can you provide
> a real example of this situation?

The example that I am mostly concerned with is:

$cd_rs->recursive_update( { title => 'New Title', artist => { name =>
'New Name' } } )

Now when traversing the relation from cd to the artist I get the
artist resultset with the PK constrained in the ->{cond}.  There is
just one artist that the cd 'belongs_to' - and that artist should be
updated.  But there is no PK passed in the parameters - so if we just
look at the parameters we would  conclude that this would require a
->create call.

If someone uses add_relationship instead of the ('belongs_to' or
'might_have' ) helpers - this becomes even more untraceable.


For a slightly more contrived example let's take User and Notes just
as you have at:
http://search.cpan.org/~groditi/DBIx-Class-Schema-RestrictWithObject-0.0001/lib/DBIx/Class/Schema/RestrictWithObject.pm
, but let's assume that the Notes table has a composite primary key
that contains 'user_id' and 'subject'.
Then one would expect that this:

$restricted_notes_rs->update_or_create( { subject => 'Some existing
subject', some_other_column => 'New Value' } )

would result in updating the Notes record with ( $user_id, 'Some
existing subject' ) in PK rather then trying (and failing) to create a
new record.

spacer
Profile | Posts (147)
Home > People > Zbigniew Lukasiak