[Dbix-class] Scalar ref update()'s

Jose Fonseca zefonseca at gmail.com
Thu May 15 20:17:04 BST 2008


Hi Marc, thanks for the tip.

I raised the issue here as a sort of RFC on whether DBIC should
reload-on-write from the RDBMS automatically when updated with a scalar
ref(literal SQL command).  It seems reasonable that it should, I don't think
the returned SQL snippet is useful under any circumstance.

Until now I was getting around it using $subscription =3D
resultset('Subscriptions')->find(); which is similar though less elegant
than your solution. Thanks.

Regards,
Jose Fonseca

On Thu, May 15, 2008 at 4:04 PM, Marc Mims <marc at questright.com> wrote:

> * Jose Fonseca <zefonseca at gmail.com> [080515 12:00]:
> > $subscription->end_date(   \'DATE_ADD(NOW(), INTERVAL 12 MONTH)'   );
> > $subscription->update();
> >
> > It works a dandy, check the row and MySQL replies with a brand new 12
> month.
> >
> > But now, whenever I read
> >
> > $end_date =3D $subscription->end_date();
> >
> > I get a reference to \'DATE_ADD(NOW(), INTERVAL 3 MONTH)' and not the n=
ew
> > computed value. It seems we're missing a back and forth trip to the
> RDBMS?
>
> Although the back-end DB has been updated, the object in memory has no
> way of knowing what value the DB assigned.  Re-read from the DB to
> update the object:
>
>   $subscription->discard_changes;
>
> -Marc
>
> _______________________________________________
> 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.rawmode.org
>



-- =

http://zefonseca.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080515/5ec=
0ef00/attachment.htm


More information about the DBIx-Class mailing list