[Bast-commits] r6428 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class/InflateColumn t t/lib/DBICTest/Schema

ash at dev.catalyst.perl.org ash at dev.catalyst.perl.org
Tue May 26 14:17:45 GMT 2009


Author: ash
Date: 2009-05-26 14:17:44 +0000 (Tue, 26 May 2009)
New Revision: 6428

Added:
   DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm
Modified:
   DBIx-Class/0.08/trunk/Changes
   DBIx-Class/0.08/trunk/Makefile.PL
   DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm
   DBIx-Class/0.08/trunk/t/89inflate_datetime.t
Log:
Fix 'timestamp with time zone' columns for IC::DT inflation


Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes	2009-05-26 07:57:49 UTC (rev 6427)
+++ DBIx-Class/0.08/trunk/Changes	2009-05-26 14:17:44 UTC (rev 6428)
@@ -31,6 +31,8 @@
         - Sybase now supports autoinc PKs (RT#40265)
         - Prefetch on joins over duplicate relations now works
           correctly (RT#28451)
+        - "timestamp with time zone" columns (for Pg) now get inflated with a
+          time zone information preserved
 
 0.08102 2009-04-30 08:29:00 (UTC)
         - Fixed two subtle bugs when using columns or select/as

Modified: DBIx-Class/0.08/trunk/Makefile.PL
===================================================================
--- DBIx-Class/0.08/trunk/Makefile.PL	2009-05-26 07:57:49 UTC (rev 6427)
+++ DBIx-Class/0.08/trunk/Makefile.PL	2009-05-26 14:17:44 UTC (rev 6428)
@@ -72,6 +72,9 @@
 
   # t/60core.t
   'DateTime::Format::MySQL'   => 0,
+  
+  # t/89inflate_datetime.t
+  'DateTime::Format::Pg'      => 0,
 
   # t/72pg.t
   $ENV{DBICTEST_PG_DSN}

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm	2009-05-26 07:57:49 UTC (rev 6427)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/InflateColumn/DateTime.pm	2009-05-26 14:17:44 UTC (rev 6428)
@@ -107,6 +107,10 @@
 
   unless ($type) {
     $type = lc($info->{data_type});
+    if ($type eq "timestamp with time zone" || $type eq "timestamptz") {
+      $type = "timestamp";
+      $info->{_ic_dt_method} ||= "timestamp_with_timezone";
+    }
   }
 
   my $timezone;

Modified: DBIx-Class/0.08/trunk/t/89inflate_datetime.t
===================================================================
--- DBIx-Class/0.08/trunk/t/89inflate_datetime.t	2009-05-26 07:57:49 UTC (rev 6427)
+++ DBIx-Class/0.08/trunk/t/89inflate_datetime.t	2009-05-26 14:17:44 UTC (rev 6428)
@@ -8,15 +8,18 @@
 {
   local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
   DBICTest::Schema->load_classes('EventTZDeprecated');
+  DBICTest::Schema->load_classes('EventTZPg');
 }
 
 my $schema = DBICTest->init_schema();
 
-eval { require DateTime::Format::MySQL };
-plan skip_all => "Need DateTime::Format::MySQL for inflation tests" if $@;
+plan tests => 53;
 
-plan tests => 50;
+SKIP: {
+  eval { require DateTime::Format::MySQL };
+  skip "Need DateTime::Format::MySQL for inflation tests", 50  if $@;
 
+
 # inflation test
 my $event = $schema->resultset("Event")->find(1);
 
@@ -142,3 +145,17 @@
 ## skip inflation field
 my $skip_inflation = $event->skip_inflation;
 is ("$skip_inflation", '2006-04-21 18:04:06', 'Correct date/time');
+
+} # Skip if no MySQL DT::Formatter
+
+SKIP: {
+
+  skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 3 unless eval { require DateTime::Format::Pg; 1};
+  my $event = $schema->resultset("EventTZPg")->find(1);
+  $event->update({created_on => '2009-01-15 17:00:00+00'});
+  $event->discard_changes;
+  isa_ok($event->created_on, "DateTime") or diag $event->created_on;
+  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");
+}

Copied: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm (from rev 6427, DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZ.pm)
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm	                        (rev 0)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm	2009-05-26 14:17:44 UTC (rev 6428)
@@ -0,0 +1,24 @@
+package DBICTest::Schema::EventTZPg;
+
+use strict;
+use warnings;
+use base qw/DBICTest::BaseResult/;
+
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+
+__PACKAGE__->table('event');
+
+__PACKAGE__->add_columns(
+  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" },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+sub _datetime_parser {
+  require DateTime::Format::Pg;
+  DateTime::Format::Pg->new();
+}
+
+1;


Property changes on: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/EventTZPg.pm
___________________________________________________________________
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + native




More information about the Bast-commits mailing list