[Bast-commits] r8525 - in DBIx-Class/0.08/trunk: . t/inflate
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Feb 3 12:21:37 GMT 2010
Author: caelum
Date: 2010-02-03 12:21:37 +0000 (Wed, 03 Feb 2010)
New Revision: 8525
Modified:
DBIx-Class/0.08/trunk/Makefile.PL
DBIx-Class/0.08/trunk/t/inflate/datetime_sybase_asa.t
Log:
test DT inflation for Sybase SQL Anywhere over ODBC too
Modified: DBIx-Class/0.08/trunk/Makefile.PL
===================================================================
--- DBIx-Class/0.08/trunk/Makefile.PL 2010-02-03 07:31:20 UTC (rev 8524)
+++ DBIx-Class/0.08/trunk/Makefile.PL 2010-02-03 12:21:37 UTC (rev 8525)
@@ -123,6 +123,11 @@
'DateTime::Format::Sybase' => 0,
) : ()
,
+ grep $_, @ENV{qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/}
+ ? (
+ 'DateTime::Format::Strptime' => 0,
+ ) : ()
+ ,
);
#************************************************************************#
# Make ABSOLUTELY SURE that nothing on the list above is a real require, #
Modified: DBIx-Class/0.08/trunk/t/inflate/datetime_sybase_asa.t
===================================================================
--- DBIx-Class/0.08/trunk/t/inflate/datetime_sybase_asa.t 2010-02-03 07:31:20 UTC (rev 8524)
+++ DBIx-Class/0.08/trunk/t/inflate/datetime_sybase_asa.t 2010-02-03 12:21:37 UTC (rev 8525)
@@ -6,12 +6,15 @@
use lib qw(t/lib);
use DBICTest;
-my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_ASA_${_}" } qw/DSN USER PASS/};
+my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_ASA_${_}" } qw/DSN USER PASS/};
+my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SYBASE_ASA_ODBC_${_}" } qw/DSN USER PASS/};
-if (not $dsn) {
- plan skip_all =>
- 'Set $ENV{DBICTEST_SYBASE_ASA_DSN}, _USER and _PASS to run this test' .
- "\nWarning: This test drops and creates a table called 'track'";
+if (not ($dsn || $dsn2)) {
+ plan skip_all => <<'EOF';
+Set $ENV{DBICTEST_SYBASE_ASA_DSN} and/or $ENV{DBICTEST_SYBASE_ASA_ODBC_DSN}
+_USER and _PASS to run this test'.
+Warning: This test drops and creates a table called 'track'";
+EOF
} else {
eval "use DateTime; use DateTime::Format::Strptime;";
if ($@) {
@@ -19,52 +22,65 @@
}
}
-my $schema;
+my @info = (
+ [ $dsn, $user, $pass ],
+ [ $dsn2, $user2, $pass2 ],
+);
-$schema = DBICTest::Schema->clone;
+my @handles_to_clean;
-$schema->connection($dsn, $user, $pass, {
- on_connect_call => [ 'datetime_setup' ],
-});
+foreach my $info (@info) {
+ my ($dsn, $user, $pass) = @$info;
+ next unless $dsn;
+
+ my $schema = DBICTest::Schema->clone;
+
+ $schema->connection($dsn, $user, $pass, {
+ on_connect_call => [ 'datetime_setup' ],
+ });
+
+ push @handles_to_clean, $schema->storage->dbh;
+
# coltype, col, date
-my @dt_types = (
- ['TIMESTAMP', 'last_updated_at', '2004-08-21 14:36:48.080444'],
+ my @dt_types = (
+ ['TIMESTAMP', 'last_updated_at', '2004-08-21 14:36:48.080444'],
# date only (but minute precision according to ASA docs)
- ['DATE', 'small_dt', '2004-08-21 00:00:00.000000'],
-);
+ ['DATE', 'small_dt', '2004-08-21 00:00:00.000000'],
+ );
-for my $dt_type (@dt_types) {
- my ($type, $col, $sample_dt) = @$dt_type;
+ 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,
-)
+ 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));
+ 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] })
- ->first
- );
- is( $row->$col, $dt, 'DateTime roundtrip' );
+ my $row;
+ ok( $row = $schema->resultset('Track')->create({
+ $col => $dt,
+ cd => 1,
+ }));
+ ok( $row = $schema->resultset('Track')
+ ->search({ trackid => $row->trackid }, { select => [$col] })
+ ->first
+ );
+ is( $row->$col, $dt, 'DateTime roundtrip' );
+ }
}
done_testing;
# clean up our mess
END {
- if (my $dbh = eval { $schema->storage->_dbh }) {
- $dbh->do('DROP TABLE track');
+ foreach my $dbh (@handles_to_clean) {
+ eval { $dbh->do("DROP TABLE $_") } for qw/track/;
}
}
More information about the Bast-commits
mailing list