Author: spadkins
Date: Thu Feb 26 11:12:04 2009
New Revision: 12546
Modified:
p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
p5ee/trunk/App-Repository/t/DBI-update.t
Log:
fixed update for Oracle (with dbexpr_update expressions such as Oracle to_date()
Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm Thu Feb 26 11:12:04 2009
@@ -1669,7 +1669,11 @@
next if ($noupdate[$colidx]);
$col = $cols->[$colidx];
next if ($noupdate{$col});
- push(@set, "$col = ?");
+ $value = "?";
+ if ($column_defs->{$col}{dbexpr_update}) {
+ $value = sprintf($column_defs->{$col}{dbexpr_update}, $value,
$value, $value, $value, $value);
+ }
+ push(@set, "$col = $value");
push(@set_bind_var_idx, $colidx);
}
}
Modified: p5ee/trunk/App-Repository/t/DBI-update.t
==============================================================================
--- p5ee/trunk/App-Repository/t/DBI-update.t (original)
+++ p5ee/trunk/App-Repository/t/DBI-update.t Thu Feb 26 11:12:04 2009
@@ -187,5 +187,18 @@
is($nrows, 3, "update(table, HASH, ARRAY, HASH) : nrows");
is($rep->{sql}, $expect_sql, "update(table, HASH, ARRAY, HASH) : sql");
+$nrows = $rep->update("test_person", 1,
+ [ "birth_dt", "change_dttm", "modify_dttm", "age",
"chess_rating", "last_name" ],
+ [ "1960-01-01", "2009-02-26 13:14:22", "2009-02-26
13:14:23", 99, 200.1, "the great" ]);
+is($nrows, 1, "update(table, [DATE,DATETIME,TIMESTAMP,INT,FLOAT,STRING])");
+my $row = $rep->get_row("test_person", 1,
+ [ "birth_dt", "change_dttm", "modify_dttm", "age",
"chess_rating", "last_name" ]);
+is($row->[0], "1960-01-01", "update() of DATE validated");
+is($row->[1], "2009-02-26 13:14:22", "update() of DATETIME validated");
+is($row->[2], "2009-02-26 13:14:23", "update() of TIMESTAMP validated");
+is($row->[3], 99, "update() of INT validated");
+is($row->[4], 200.1, "update() of FLOAT validated");
+is($row->[5], "the great", "update() of STRING validated");
+
exit 0;