>...instance, I might want to set a column to \'NOW()' and have repeated, >future updates bump the timestamp without having to explicitly set the >timestamp column each time.
I'm not sure I follow. The problem is with reading back the value, not writing. Also to bump the timestamp you need a round trip to the DB. >So, reading the value from the DB should only be done at the user's >request. An update_and_refresh might be handy, but it's really not Yep, totally agree. After giving it some thought too I think it oughta be separated, though documented. >necessary. Since update returns $self, you could just: > $row->update->discard_changes; I propose then this gets documented on some future revision, because discard_changes does not sound like something that would refresh new values. Regards. On Fri, May 16, 2008 at 2:41 PM, Marc Mims <[EMAIL PROTECTED]> wrote: > * Jose Fonseca <[EMAIL PROTECTED]> [080516 10:30]: > > A technical solution would involve what Ash called "too much magic", and > I > > sort of agree**. Also keeping it in 2 functions would keep the system > well > > decoupled instead of bloating it up(TMM again). > > > > [snip] > > > > ** The reason I don't agree completely is that, as explained above, > > returning the scalar ref does not make any sense at all in update(). In > my > > opinion if we create a 2nd function, we should throw an immediate > exception > > when update is used with a scalar ref value to force it to break early > and > > let the developer know it's being used incorrectly. In my case I just > wrote > > that code assuming I'd get the date back because that scalar ref has > nothing > > to be doing in my Perl code. > > Having given it some thought, I completely agree that it's too much > magic. It may, in fact, be undesirable in some circumstances. For > instance, I might want to set a column to \'NOW()' and have repeated, > future updates bump the timestamp without having to explicitly set the > timestamp column each time. > > So, reading the value from the DB should only be done at the user's > request. An update_and_refresh might be handy, but it's really not > necessary. Since update returns $self, you could just: > > $row->update->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/[EMAIL PROTECTED] > -- http://zefonseca.com/
_______________________________________________ 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/[EMAIL PROTECTED]
