[Dbix-class] Bug(?) in find_or_create with sub-queries

Toby Corkindale toby at dryft.net
Mon Dec 20 00:44:11 GMT 2010


On 17 December 2010 01:43, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
> Toby Corkindale wrote:
>>
>> I think I have found a bug in find_or_create(), although maybe it's
>> more a case of "it should throw an error if you try this", instead of
>> silenting doing the Wrong Thing.
>>
>> Viz:
>>
>> Assume you have these tables:
>> table1, with columns "luser" and "role".
>> The primary key is on "luser, role".
>> "role" is a foreign key into table2..
>>
>> table2 has columns "id" and "name".
>>
>> my $rs = $schema->resultset('table1');
>> $rs->find_or_create(
>>  {
>>    luser => 'john',
>>    role => { name => 'Admin' },
>>  }
>> );
>>
>> In this case, the SELECT that dbix class does to try and find the user
>> will be WHERE luser='john' AND role=NULL.
>
> Are you saying this is what DBIC does *now*? or this is part
> of a wishlist description? If this is in fact the SQL you see
> please let me know which DBIC version is this.

This is what DBIC is doing now.

DBIC 0.08124



More information about the DBIx-Class mailing list