[Dbix-class] Bug with relationships on new objects.

brett gardner brett at clientcomm.com.au
Mon Jan 7 03:43:16 GMT 2008


The offending line is on line 793 of ResultSource.pm

$ret{$k} = $for->get_column($v) if $for->has_column_loaded($v);

Changing to

$ret{$k} = $for->get_column($v);

Fixes the problem for me, but breaks the tests

 my $undef_artist_cd = $schema->resultset("CD")->new_result({ 'title' => 
'badgers', 'year' => 2007 });
207 is($undef_artist_cd->has_column_loaded('artist'), '', 'FK not loaded');
208 is($undef_artist_cd->search_related('artist')->count, 3, 'open 
search on undef FK');

in 66relationship.t

brett gardner wrote:
> I have a schema where there are clients who have subscribers.
>
> So there is an object "Client" which has a has_many relationship to 
> "Subscriber".
>
> If I do the following
>
> my $client = $app->schema->resultset('Client')->find(...);
> my $subscribers = $client->subscribers;
>
> Then the relationship is correct and only pulls out the subscribers 
> attached to that client.
>
> But if I do the following.
>
> my $client = $app->schema->resultset('Client')->new({});
> my $subscribers = $client->subscribers;
>
> Then all the subscribers are pulled out which is not ideal and 
> potentially a very embarrassing privacy breach. Looking at the SQL 
> generated by "$client->subscribers" it is not putting in the limiting 
> where clause "WHERE me.client_id = ..."
>
> This is occurring in version 0.08008.
>
> Brett
>
>
>
> _______________________________________________
> 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.rawmode.org
>
>



More information about the DBIx-Class mailing list