[Dbix-class] A timestamp field is null when a record is created

Alexander Hartmaier alexander.hartmaier at t-systems.at
Tue Oct 30 13:06:53 GMT 2012


On 2012-10-30 14:02, Peter Rabbitson wrote:
> On Tue, Oct 30, 2012 at 01:54:38PM +0100, Alexander Hartmaier wrote:
>> $obj->discard_changes;
>> because the database assigns the column value on insert but DBIC doesn't
>> fetch it from he db.
> Please do not use/recommend discard_changes() for this use-case. d_s()
> is too heavy as it refetches *everything* from the database. What the OP
> wants to achieve is done by using the colinfo flag retrieve_on_insert[1]
I wasn't sure if that already exists, great!
I always recommend to assign default values in the model and don't rely
on the database, DBIx::Class::TimeStamp with set_on_create in that case.
>
> Cheers
>
> [1] http://search.cpan.org/~frew/DBIx-Class-0.08203/lib/DBIx/Class/ResultSource.pm#retrieve_on_insert
>
> _______________________________________________
> 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



*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list