[Bast-commits] r7137 - in DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t: inflate lib/DBICTest/Schema

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Thu Jul 30 08:12:46 GMT 2009


Author: caelum
Date: 2009-07-30 08:12:45 +0000 (Thu, 30 Jul 2009)
New Revision: 7137

Modified:
   DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/inflate/datetime_mssql.t
   DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/lib/DBICTest/Schema/Track.pm
Log:
better tests for "smalldatetime" support in MSSQL

Modified: DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/inflate/datetime_mssql.t
===================================================================
--- DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/inflate/datetime_mssql.t	2009-07-29 22:33:21 UTC (rev 7136)
+++ DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/inflate/datetime_mssql.t	2009-07-30 08:12:45 UTC (rev 7137)
@@ -27,8 +27,11 @@
 $schema->connection($dsn, $user, $pass);
 $schema->storage->ensure_connected;
 
+# coltype, column, datehash
 my @dt_types = (
-  ['DATETIME', {
+  ['DATETIME',
+   'last_updated_at',
+   {
     year => 2004,
     month => 8,
     day => 21,
@@ -37,7 +40,9 @@
     second => 48,
     nanosecond => 500000000,
   }],
-  ['SMALLDATETIME', { # minute precision
+  ['SMALLDATETIME', # minute precision
+   'small_dt',
+   {
     year => 2004,
     month => 8,
     day => 21,
@@ -47,7 +52,7 @@
 );
 
 for my $dt_type (@dt_types) {
-  my ($type, $sample_dt) = @$dt_type;
+  my ($type, $col, $sample_dt) = @$dt_type;
 
   eval { $schema->storage->dbh->do("DROP TABLE track") };
   $schema->storage->dbh->do(<<"SQL");
@@ -55,21 +60,21 @@
  trackid INT IDENTITY PRIMARY KEY,
  cd INT,
  position INT,
- last_updated_on $type,
+ $col $type,
 )
 SQL
   ok(my $dt = DateTime->new($sample_dt));
 
   my $row;
   ok( $row = $schema->resultset('Track')->create({
-        last_updated_on => $dt,
+        $col => $dt,
         cd => 1,
       }));
   ok( $row = $schema->resultset('Track')
-    ->search({ trackid => $row->trackid }, { select => ['last_updated_on'] })
+    ->search({ trackid => $row->trackid }, { select => [$col] })
     ->first
   );
-  is( $row->updated_date, $dt, 'DateTime roundtrip' );
+  is( $row->$col, $dt, 'DateTime roundtrip' );
 }
 
 # clean up our mess

Modified: DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/lib/DBICTest/Schema/Track.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/lib/DBICTest/Schema/Track.pm	2009-07-29 22:33:21 UTC (rev 7136)
+++ DBIx-Class/0.08/branches/mssql_storage_minor_refactor/t/lib/DBICTest/Schema/Track.pm	2009-07-30 08:12:45 UTC (rev 7137)
@@ -30,6 +30,10 @@
     data_type => 'datetime',
     is_nullable => 1
   },
+  small_dt => { # for mssql and sybase DT tests
+    data_type => 'smalldatetime',
+    is_nullable => 1
+  },
 );
 __PACKAGE__->set_primary_key('trackid');
 




More information about the Bast-commits mailing list