[Bast-commits] r7091 - in
DBIx-Class/0.08/branches/mssql_money_type/t: . lib/DBICTest
lib/DBICTest/Schema
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Thu Jul 23 12:34:01 GMT 2009
Author: caelum
Date: 2009-07-23 12:34:01 +0000 (Thu, 23 Jul 2009)
New Revision: 7091
Added:
DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema/Money.pm
Modified:
DBIx-Class/0.08/branches/mssql_money_type/t/746mssql.t
DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema.pm
Log:
add test
Modified: DBIx-Class/0.08/branches/mssql_money_type/t/746mssql.t
===================================================================
--- DBIx-Class/0.08/branches/mssql_money_type/t/746mssql.t 2009-07-23 12:24:39 UTC (rev 7090)
+++ DBIx-Class/0.08/branches/mssql_money_type/t/746mssql.t 2009-07-23 12:34:01 UTC (rev 7091)
@@ -12,7 +12,7 @@
plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test'
unless ($dsn && $user);
-plan tests => 27;
+plan tests => 29;
my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
@@ -75,8 +75,32 @@
is( $it->next->name, "Artist 2", "iterator->next ok" );
is( $it->next, undef, "next past end of resultset ok" );
+# test MONEY type
$schema->storage->dbh_do (sub {
my ($storage, $dbh) = @_;
+ eval { $dbh->do("DROP TABLE money_test") };
+ $dbh->do(<<'SQL');
+
+CREATE TABLE money_test (
+ id INT IDENTITY PRIMARY KEY,
+ amount money
+)
+
+SQL
+
+});
+
+my $rs = $schema->resultset('Money');
+
+my $row;
+lives_ok {
+ $row = $rs->create({ amount => \'cast(100.00 as money)' });
+} 'inserted a money value';
+
+is $rs->find($row->id)->amount, '100.00', 'money value round-trip';
+
+$schema->storage->dbh_do (sub {
+ my ($storage, $dbh) = @_;
eval { $dbh->do("DROP TABLE Owners") };
eval { $dbh->do("DROP TABLE Books") };
$dbh->do(<<'SQL');
@@ -232,7 +256,11 @@
# clean up our mess
END {
- my $dbh = eval { $schema->storage->_dbh };
- $dbh->do('DROP TABLE artist') if $dbh;
+ if (my $dbh = eval { $schema->storage->_dbh }) {
+ $dbh->do('DROP TABLE artist');
+ $dbh->do('DROP TABLE money_test');
+ $dbh->do('DROP TABLE Books');
+ $dbh->do('DROP TABLE Owners');
+ }
}
# vim:sw=2 sts=2
Added: DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema/Money.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema/Money.pm (rev 0)
+++ DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema/Money.pm 2009-07-23 12:34:01 UTC (rev 7091)
@@ -0,0 +1,21 @@
+package # hide from PAUSE
+ DBICTest::Schema::Money;
+
+use base qw/DBICTest::BaseResult/;
+
+__PACKAGE__->table('money_test');
+
+__PACKAGE__->add_columns(
+ 'id' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ 'amount' => {
+ data_type => 'money',
+ is_nullable => 1,
+ },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Modified: DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema.pm 2009-07-23 12:24:39 UTC (rev 7090)
+++ DBIx-Class/0.08/branches/mssql_money_type/t/lib/DBICTest/Schema.pm 2009-07-23 12:34:01 UTC (rev 7091)
@@ -21,6 +21,7 @@
Year2000CDs
Year1999CDs
CustomSql
+ Money
/,
{ 'DBICTest::Schema' => [qw/
LinerNotes
More information about the Bast-commits
mailing list