[Dbix-class] Using a scalar ref with update_or_create

Will Crawford billcrawford1970 at gmail.com
Mon Mar 19 12:50:27 GMT 2012


On 19 March 2012 12:33, Websuche :: Felix Ostmann <ostmann at websuche.de> wrote:
> We run into the same problem and simple split the problem. Make a find, then
> update or create (simple look what update_or_create do internally)
>
> 2012/3/19 Will Crawford <billcrawford1970 at gmail.com>
>>
>> change the value to \'CURRENT_TIMESTAMP' or \'CURRENT_DATE' :)
>
>
> read again ;) that was not the problem ...

Well, it might be a problem in the future (as in prepared statements
it'll get optimised to a fixed value; we had to change our code to use
CURRENT_TIMESTAMP instead of 'now'). But I see what you mean :) sorry.

You can fix it by adding the "key" attribute in the second parameter
to update_or_create, to tell it to use a different index (not one
including the date column) to search for the existing row.



More information about the DBIx-Class mailing list