From: Rafael Kitover Date: Thu, 23 Jul 2009 15:01:37 +0000 (+0000) Subject: add test for updating money value to NULL X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f6b185e1397cb9003caa601e372d300c11086e5d;p=dbsrgits%2FDBIx-Class-Historic.git add test for updating money value to NULL --- diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index 21885d4..48f281b 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -44,9 +44,8 @@ sub _prep_for_execute { my $col_info = $self->_resolve_column_info($ident, [keys %$fields]); for my $col (keys %$fields) { - if ($col_info->{$col}{data_type} eq 'money') { + if ($col_info->{$col}{data_type} =~ /^money\z/i) { my $val = $fields->{$col}; - $fields->{$col} = \['CAST(? AS MONEY)', [ $col => $val ]]; } } diff --git a/t/746mssql.t b/t/746mssql.t index 09f065f..ebb5a85 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -12,7 +12,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PA plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 31; +plan tests => 33; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); @@ -105,6 +105,12 @@ lives_ok { is $rs->find($row->id)->amount, '200.00', 'updated money value round-trip'; +lives_ok { + $row->update({ amount => undef }); +} 'updated a money value to NULL'; + +is $rs->find($row->id)->amount, undef,'updated money value to NULL round-trip'; + $schema->storage->dbh_do (sub { my ($storage, $dbh) = @_; eval { $dbh->do("DROP TABLE Owners") };