2009/2/17 Daniel Westermann-Clark <[email protected]>:
> On 2009-02-17 17:15:05 +0100, Zbigniew Lukasiak wrote:
>> > So what I should I pass to 'id', nothing?
>>
>> Yeah - this is the problem.  The official answer is that you should
>> not use find_or_create on tables with auto-increment pks - you should
>> use 'create' or 'find' as appriopriate instead.
>
> No, the official answer is not to pass a value for a column that you
> want the database to fill.  undef means null in other places to DBIC;
> why should find_or_create be different?
>
> find_or_create and friends work fine on tables with auto-increment
> keys.  I use it all the time.

There looks to be allowances for auto-incrementing keys

>From the deprecated PK::Auto module
"Just load PK::Auto instead; auto-inc is now handled by Storage."

It would be a bit pain to have to do a search first, it kinda removes
the purpose of having a find_or_create method.

I'll go with the plan of not passing the id..

>Ah - yeah - I should have add if you don't have any other unique key.

I do have a UNIQUE Constraint on one of the fields. I hope that not
going to bit me in the proverbial as well.
Dp.

_______________________________________________
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/[email protected]

Reply via email to