my $self = shift;
my ($op, $extra_bind, $ident, $args) = @_;
+# cast MONEY values properly
+ if ($op eq 'insert' || $op eq 'update') {
+ my $fields = $args->[0];
+ my $col_info = $self->_resolve_column_info($ident, [keys %$fields]);
+
+ for my $col (keys %$col_info) {
+ if ($col_info->{$col}{data_type} eq 'money') {
+ my $val = $fields->{$col};
+
+ $fields->{$col} = \['CAST(? AS MONEY)', [ $col => $val ]];
+ }
+ }
+ }
+
my ($sql, $bind) = $self->next::method (@_);
if ($op eq 'insert') {
plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test'
unless ($dsn && $user);
-plan tests => 29;
+plan tests => 31;
my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
my $row;
lives_ok {
- $row = $rs->create({ amount => \'cast(100.00 as money)' });
+ $row = $rs->create({ amount => 100 });
} 'inserted a money value';
is $rs->find($row->id)->amount, '100.00', 'money value round-trip';
+lives_ok {
+ $row->update({ amount => 200 });
+} 'updated a money value';
+
+is $rs->find($row->id)->amount, '200.00', 'updated money value round-trip';
+
$schema->storage->dbh_do (sub {
my ($storage, $dbh) = @_;
eval { $dbh->do("DROP TABLE Owners") };