Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat undef like blessed objects for the purpose of looking for special handling #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ my $test_requires = {
#
'Sub::Uplevel' => '0.19',

'DateTime' => '1.18',
'DateTime::Format::SQLite' => '0.11',

# this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
# remove and do a manual glob-collection if n::c is no longer a dep
'Package::Stash' => '0.28',
Expand Down
41 changes: 41 additions & 0 deletions t/inflate/undef.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }

use strict;
use warnings;

use Test::More;

use DateTime;

use DBICTest;
my $schema = DBICTest->init_schema();

my $date = DateTime->new(year => 1900, month => 1, day => 1);

my $res = $schema->resultset('Event')->create({ starts_at => $date, created_on => DateTime->now(), });

$res->varchar_datetime($date);
is($res->varchar_datetime, $date, 'Setting an inflated column to an object stores the right value in the object');
isa_ok($res->varchar_datetime, 'DateTime', 'Can store objects in inflated columns');

$res->varchar_datetime($date);
$res->varchar_datetime(undef);
is($res->varchar_datetime, undef, 'After storing undef in an object using the accessor, the accessor returns the right value');
is($res->get_inflated_column('varchar_datetime'), undef, '. . . and get_inflated_column returns the right value');
is($res->get_column('varchar_datetime'), undef, '. . . and get_column returns the right value');

$res->varchar_datetime($date);
$res->set_inflated_columns({ varchar_datetime => undef, });
is($res->varchar_datetime, undef, 'After storing undef in an object using set_inflated_columns, the accessor returns the right value');
is($res->get_inflated_column('varchar_datetime'), undef, '. . . and get_inflated_column returns the right value');
is($res->get_column('varchar_datetime'), undef, '. . . and get_column returns the right value');

$res->varchar_datetime($date);
$res->set_inflated_column(varchar_datetime => undef);
is($res->varchar_datetime, undef, 'After storing undef in an object using set_inflated_column, the accessor returns the right value');
is($res->get_inflated_column('varchar_datetime'), undef, '. . . and get_inflated_column returns the right value');
is($res->get_column('varchar_datetime'), undef, '. . . and get_column returns the right value');

undef $res;

done_testing();