[Dbix-class] Re: set_on_update=>0

will trillich will.trillich at serensoft.com
Thu Jul 21 03:00:02 GMT 2011


This is quite puzzling!

$item->as_of( "2001-12-31 23:59:59" );
$params->{as_of} =3D "2005-05-05 05:05:05";
$form->process( item =3D> $item, params =3D> $params );
# here, $item->as_of is CURRENT_TIMESTAMP regardless!

We're wanting to keep the timestamp as-is, not
set-to-current-timestamp-upon-every-update.

Using HTML::FormHandler (v0.32005) to process the $form, it doesn't seem to
matter what we stuff into the $params->{as_of} field, or what we inject into
the $item->as_of() field itself, it gets set to current timestamp no matter
what. All suggestions and clue-sticks welcome.

In MyApp::Schema::DB::Result::MyTable we override the db field completely:

__PACKAGE__->add_columns('as_of',
    {
#       %{__PACKAGE__->column_info('as_of')},
    data_type =3D> 'timestamp',
    datetime_undef_if_invalid =3D> 1,
#   default_value =3D> \"current_timestamp",
    is_nullable =3D> 0,
#       set_on_create =3D> 1,
#       *set_on_update =3D> 0*, # ignored wholesale from what we can tell
    } );

So there's no "set_on_create" or "set_on_update" at all:

  DB<10> x $item->column_info('as_of')
0  HASH(0xd7d2538)
   '_ic_dt_method' =3D> 'timestamp'
   '_inflate_info' =3D> HASH(0xd7d8fd0)
      'deflate' =3D> CODE(0xd7d90d0)
         ->
&DBIx::Class::InflateColumn::DateTime::__ANON__[/usr/local/share/perl/5.10.=
0/DBIx/Class/InflateColumn/DateTime.pm:190]
in /usr/local/share/perl/5.10.0/DBIx/Class/InflateColumn/DateTime.pm:185-190
      'inflate' =3D> CODE(0xd7d1e68)
         ->
&DBIx::Class::InflateColumn::DateTime::__ANON__[/usr/local/share/perl/5.10.=
0/DBIx/Class/InflateColumn/DateTime.pm:184]
in /usr/local/share/perl/5.10.0/DBIx/Class/InflateColumn/DateTime.pm:169-184
   'data_type' =3D> 'timestamp'
   'datetime_undef_if_invalid' =3D> 1
   'is_nullable' =3D> 0
   'name' =3D> 'as_of'

"Jane! How do I stop this crazy thing?!" Pointers welcome.


On Tue, Jul 19, 2011 at 3:53 PM, will trillich
<will.trillich at serensoft.com>wrote:

> Been using DBIx::Class (v0.08127) for a while now with Catalyst (v5.80032)
> and Moose (v1.24), what a great suite of powerful libraries!
>
> Question on how to turn OFF or DISABLE *set_on_update* tho:
>
> __PACKAGE__->add_columns('as_of',
>     {
>         %{__PACKAGE__->column_info('as_of')},
>         set_on_create =3D> 1,
> #       set_on_update =3D> 0,
>     } );
>
> The set_on_create is working as expected. The set_on_update seems to work
> whether we specify 1 or 0 or leave the declaration out altogether.
>
> Is there another setting somewhere that interferes?
>
>
> --
> "Don't just accept the benefits of civilization -- add to it. Extend it.
> Preserve it." -- Jeff Greason
>



-- =

"Don't just accept the benefits of civilization -- add to it. Extend it.
Preserve it." -- Jeff Greason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110720/faa=
0e24b/attachment.htm


More information about the DBIx-Class mailing list