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

Reply via email to