[Dbix-class] Using a scalar ref with update_or_create

Will Crawford billcrawford1970 at gmail.com
Mon Mar 19 12:03:39 GMT 2012


change the value to \'CURRENT_TIMESTAMP' or \'CURRENT_DATE' :)

if this isn't a long-running process, 'now' (without the parentheses)
will probably work.

On 16 March 2012 20:32, Octavian Rasnita <orasnita at gmail.com> wrote:
> Hi,
>
> I have tried to use:
>
> $self->update_or_create({
>  symbol => $symbol,
>  market => $market,
>  last_update => \'now()',
> });
>
> Am I doing something wrong?
>
> The problem is the row:
>  last_update => \'now()',
>
> ...because the generated SQL for select looks like:
> SELECT ... FROM table_name me WHERE ( ( ... AND me.last_update now() AND ... )
>
> If I add an "=" in that line like:
>  last_update => \'=now()',
>
> ...then I got another error because the generated SQL for insert becomes:
> INSERT INTO table_name(...) VALUES ( ?, =now(), ?, ... )
>
> Isn't possible to use a DB function with update_or_create?
>
> In this case I can send a DateTime string instead of \'now()' but in other cases it might be impossible...
>
> Thanks.
>
> Octavian
>
>
> _______________________________________________
> 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.scsys.co.uk



More information about the DBIx-Class mailing list