Re: Calling a set_sql created method after a create() has NULL __IDENTIFIER__.

[prev] [thread] [next] [Date index for 2004/06/22]

From: Tony Bowden
Subject: Re: Calling a set_sql created method after a create() has NULL __IDENTIFIER__.
Date: 20:32 on 22 Jun 2004
On Mon, Jun 21, 2004 at 08:31:28PM +0100, Rob Andrews wrote:
> Test->columns(All => qw/foo bar baz/);
> Test->set_sql('refresh_bar' => qq{
>   UPDATE __TABLE__
>      SET bar=NOW()
>    WHERE __IDENTIFIER__
> });
> 
> And am calling the following code:
> 
> my $test=Test->create({ baz => 'test data goes here' });
> $test->sql_refresh_timestamp->execute;

With a little more time to consider this, this is always going fail.

You need to be calling $test->sql_refresh_timestamp->execute($test->id)

The __IDENTIFIER__ gets expanded to 'foo = ?', so you still need to pass
the id of the object you're dealing with. it's not quite *that* magic.

Tony

Re: Calling a set_sql created method after a create() has NULL __IDENTIFIER__.
Tony Bowden 20:32 on 22 Jun 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52