[Bast-commits] r7126 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/InflateColumn t/inflate t/lib/DBICTest/Schema
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Tue Jul 28 00:03:48 GMT 2009
Author: caelum
Date: 2009-07-28 00:03:47 +0000 (Tue, 28 Jul 2009)
New Revision: 7126
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm
DBIx-Class/0.08/trunk/t/inflate/datetime_pg.t
DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Event.pm
DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm
Log:
add postgres "timestamp without time zone" support
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm 2009-07-27 01:48:35 UTC (rev 7125)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm 2009-07-28 00:03:47 UTC (rev 7126)
@@ -119,6 +119,9 @@
if ($type eq "timestamp with time zone" || $type eq "timestamptz") {
$type = "timestamp";
$info->{_ic_dt_method} ||= "timestamp_with_timezone";
+ } elsif ($type eq "timestamp without time zone") {
+ $type = "timestamp";
+ $info->{_ic_dt_method} ||= "timestamp_without_timezone";
} elsif ($type eq "smalldatetime") {
$type = "datetime";
$info->{_ic_dt_method} ||= "datetime";
Modified: DBIx-Class/0.08/trunk/t/inflate/datetime_pg.t
===================================================================
--- DBIx-Class/0.08/trunk/t/inflate/datetime_pg.t 2009-07-27 01:48:35 UTC (rev 7125)
+++ DBIx-Class/0.08/trunk/t/inflate/datetime_pg.t 2009-07-28 00:03:47 UTC (rev 7126)
@@ -13,7 +13,7 @@
eval { require DateTime::Format::Pg };
plan $@
? ( skip_all => 'Need DateTime::Format::Pg for timestamp inflation tests')
- : ( tests => 3 )
+ : ( tests => 6 )
;
@@ -27,4 +27,14 @@
is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
# Time zone difference -> -6hours
is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
+
+# test 'timestamp without time zone'
+ my $dt = DateTime->from_epoch(epoch => time);
+ $dt->set_nanosecond(int 500_000_000);
+ $event->update({ts_without_tz => $dt});
+ $event->discard_changes;
+ isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
+ is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
+ is($event->ts_without_tz->microsecond, $dt->microsecond,
+ 'timestamp without time zone microseconds survived');
}
Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Event.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Event.pm 2009-07-27 01:48:35 UTC (rev 7125)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Event.pm 2009-07-28 00:03:47 UTC (rev 7126)
@@ -15,6 +15,7 @@
varchar_date => { data_type => 'varchar', inflate_date => 1, size => 20, is_nullable => 1 },
varchar_datetime => { data_type => 'varchar', inflate_datetime => 1, size => 20, is_nullable => 1 },
skip_inflation => { data_type => 'datetime', inflate_datetime => 0, is_nullable => 1 },
+ ts_without_tz => { data_type => 'datetime', is_nullable => 1 }, # used in EventTZPg
);
__PACKAGE__->set_primary_key('id');
Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm 2009-07-27 01:48:35 UTC (rev 7125)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm 2009-07-28 00:03:47 UTC (rev 7126)
@@ -12,6 +12,7 @@
id => { data_type => 'integer', is_auto_increment => 1 },
starts_at => { data_type => 'datetime', timezone => "America/Chicago", locale => 'de_DE' },
created_on => { data_type => 'timestamp with time zone', timezone => "America/Chicago" },
+ ts_without_tz => { data_type => 'timestamp without time zone' },
);
__PACKAGE__->set_primary_key('id');
More information about the Bast-commits
mailing list