Warn about non-integer values for all integer bind types, not just SQL_INTEGER
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
CommitLineData
40f75181 1use strict;
2use warnings;
3
4use Test::More;
49bceca3 5use Test::Warn;
199fbc45 6use DBIx::Class::Optional::Dependencies ();
40f75181 7use lib qw(t/lib);
8use DBICTest;
9
68de9438 10plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg')
11 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg');
12
40f75181 13{
14 local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
15 DBICTest::Schema->load_classes('EventTZPg');
16}
17
40f75181 18my $schema = DBICTest->init_schema();
19
49bceca3 20warnings_are {
40f75181 21 my $event = $schema->resultset("EventTZPg")->find(1);
22 $event->update({created_on => '2009-01-15 17:00:00+00'});
23 $event->discard_changes;
24 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
25 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
26 # Time zone difference -> -6hours
27 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
65b386df 28
29# test 'timestamp without time zone'
30 my $dt = DateTime->from_epoch(epoch => time);
31 $dt->set_nanosecond(int 500_000_000);
32 $event->update({ts_without_tz => $dt});
33 $event->discard_changes;
34 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
35 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
36 is($event->ts_without_tz->microsecond, $dt->microsecond,
37 'timestamp without time zone microseconds survived');
49bceca3 38} [], 'No warnings during DT manipulations';
68de9438 39
40done_testing;