[Dbix-class] Using a scalar ref with update_or_create

Octavian Rasnita orasnita at gmail.com
Fri Mar 16 20:32:32 GMT 2012


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




More information about the DBIx-Class mailing list