From: Rafael Kitover Date: Wed, 22 Dec 2010 14:22:56 +0000 (-0500) Subject: Fix missed t/inflate/datetime_sqlanywhere.t migration to standalone small_dt X-Git-Tag: v0.08125~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=7bef80f14073af54d8743f99861fed1a9b9482b3 Fix missed t/inflate/datetime_sqlanywhere.t migration to standalone small_dt --- diff --git a/t/inflate/datetime_sqlanywhere.t b/t/inflate/datetime_sqlanywhere.t index b74e788..5b5b866 100644 --- a/t/inflate/datetime_sqlanywhere.t +++ b/t/inflate/datetime_sqlanywhere.t @@ -14,7 +14,7 @@ if (not ($dsn || $dsn2)) { plan skip_all => <<'EOF'; Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN} _USER and _PASS to run this test'. -Warning: This test drops and creates a table called 'track'"; +Warning: This test drops and creates a table called 'event'"; EOF } @@ -36,39 +36,44 @@ foreach my $info (@info) { $schema = DBICTest::Schema->clone; $schema->connection($dsn, $user, $pass, { - on_connect_call => [ 'datetime_setup' ], + on_connect_call => 'datetime_setup', }); my $sg = Scope::Guard->new(\&cleanup); + eval { $schema->storage->dbh->do('DROP TABLE event') }; + $schema->storage->dbh->do(<<"SQL"); + CREATE TABLE event ( + id INT IDENTITY PRIMARY KEY, + created_on TIMESTAMP, + starts_at DATE + ) +SQL + # coltype, col, date my @dt_types = ( - ['TIMESTAMP', 'last_updated_at', '2004-08-21 14:36:48.080445'], + [ + 'TIMESTAMP', + 'created_on', + '2004-08-21 14:36:48.080445', + ], # date only (but minute precision according to ASA docs) - ['DATE', 'small_dt', '2004-08-21 00:00:00.000000'], + [ + 'DATE', + 'starts_at', + '2004-08-21 00:00:00.000000', + ], ); for my $dt_type (@dt_types) { my ($type, $col, $sample_dt) = @$dt_type; - eval { $schema->storage->dbh->do("DROP TABLE track") }; - $schema->storage->dbh->do(<<"SQL"); - CREATE TABLE track ( - trackid INT IDENTITY PRIMARY KEY, - cd INT, - position INT, - $col $type, - ) -SQL ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt)); my $row; - ok( $row = $schema->resultset('Track')->create({ - $col => $dt, - cd => 1, - })); - ok( $row = $schema->resultset('Track') - ->search({ trackid => $row->trackid }, { select => [$col] }) + ok( $row = $schema->resultset('Event')->create({ $col => $dt, })); + ok( $row = $schema->resultset('Event') + ->search({ id => $row->id }, { select => [$col] }) ->first ); is( $row->$col, $dt, "$type roundtrip" ); @@ -83,6 +88,6 @@ done_testing; # clean up our mess sub cleanup { if (my $dbh = $schema->storage->dbh) { - eval { $dbh->do("DROP TABLE $_") } for qw/track/; + eval { $dbh->do("DROP TABLE $_") } for qw/event/; } }