the equality check).
Remove the stringification to shield broken equality since DateTime seems
to work.
This also shuts up a warning in GetSet when you set to an undef value.
Test that.
Change from bitwise xor to regular xor since bitwise is overkill and nobody
knows what ^ is.
sub set {
my($self, %data) = @_;
-
- # set_columns() is going to do a string comparison before setting.
- # This breaks on DateTime objects (whose comparison is arguably broken)
- # so we stringify anything first.
- $data{$_} = "$data{$_}" for keys %data;
return shift->set_columns(\%data);
}
my $old = $self->get_column($column);
my $ret = $self->store_column(@_);
$self->{_dirty_columns}{$column} = 1
- if (defined $old ^ defined $ret) || (defined $old && $old ne $ret);
+ if (defined $old xor defined $ret) || (defined $old && $old ne $ret);
# XXX clear out the relation cache for this column
delete $self->{related_resultsets}{$column};
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More;
+use Test::NoWarnings;
+
+BEGIN {
+ eval "use DBIx::Class::CDBICompat;";
+ plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"
+ if $@;
+ plan skip_all => "DateTime required" unless eval { require DateTime };
+ plan tests => 1;
+}
+
+{
+ package Thing;
+
+ use base 'DBIx::Class::Test::SQLite';
+
+ Thing->columns(All => qw[thing_id this that date]);
+}
+
+my $thing = Thing->construct({ thing_id => 23, this => 42 });
+$thing->set( this => undef );
+$thing->discard_changes;
use strict;
use Test::More;
+use Test::Exception;
BEGIN {
eval "use DBIx::Class::CDBICompat;";
}
my $thing = Thing->construct({ thing_id => 23, date => "01-02-1994" });
-eval {
- $thing->set( date => DateTime->now );
+my $date = DateTime->now;
+lives_ok {
+ $thing->set( date => $date );
+ $thing->set( date => $date );
};
-is $@, '';
+
+
$thing->discard_changes;