Looks like bug. Even if you try to use non ref data inside update, column data didn't updated (actually updated, but not inflated data)
$foo->update({ ts => '2010-02-05' }); But this will do the trick: delete $foo->{_inflated_column}{ts}; So, possibly this string should be placed into DBIx::Class::Row::set_inflated_columns. Here is patch (I use v0.082820): $ cat Row.pm.patch --- Row.pm_ 2015-05-23 00:17:57.574979705 +0300 +++ Row.pm 2015-05-23 00:20:46.498736716 +0300 @@ -1113,6 +1113,9 @@ $self->set_inflated_column($key, delete $upd->{$key}); } } + else { + delete $self->{_inflated_column}{$key}; + } } $self->set_columns($upd); } On 22 May 2015 at 22:57, Lasse Makholm <la...@unity3d.com> wrote: > It seems DBIx::Class::InflateColumn::DateTime does not update the inflated > column value on: $row->update({ ts_column => undef }) > > Given: > > CREATE TABLE `foo` ( > `id` bigint(20) NOT NULL AUTO_INCREMENT, > `ts` timestamp NULL DEFAULT NULL, > PRIMARY KEY (`id`) > ) ENGINE=InnoDB; > > Doing: > > package My::Schema; > > use DateTime; > use base qw(DBIx::Class::Schema::Loader); > > __PACKAGE__->loader_options( > components => [qw(InflateColumn::DateTime)], > naming => "current", > ); > > package main; > > my $schema = My::Schema->connect("dbi:mysql:test"); > $schema->storage->debug(1); > > print "create"; > my $foo = $schema->resultset('Foo')->create({ ts => DateTime->now }); > print "ts = ", defined($foo->ts) ? $foo->ts : 'null'; > > print "update({ ts => undef })"; > $foo->update({ ts => undef }); > print "ts = ", defined($foo->ts) ? $foo->ts : 'null'; > > print "discard_changes"; > $foo->discard_changes; > print "ts = ", defined($foo->ts) ? $foo->ts : 'null'; > > Yields: > > create > BEGIN WORK > INSERT INTO `foo` ( `ts`) VALUES ( ? ): '2015-05-22 19:44:54' > COMMIT > ts = 2015-05-22T19:44:54 > > update({ ts => undef }) > UPDATE `foo` SET `ts` = ? WHERE ( `id` = ? ): NULL, '16' > ts = 2015-05-22T19:44:54 > > discard_changes > SELECT `me`.`id`, `me`.`ts` FROM `foo` `me` WHERE ( `me`.`id` = ? ): '16' > ts = null > > I would have expected the inflated column value to be updated on update({ > ... }). > > Passing a DateTime object instead of undef does update the inflated column > value appropriately. > And doing: > > $row->ts_column(undef); > $row->update(); > > ...(obviously) works as expected too. > > Is this a known bug or by design? Or am I simply missing something? > > Thanx > /L > > _______________________________________________ > 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 -- //wbr, Dmitry L. _______________________________________________ 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