Subject: | Test that update() throws out it's data and reloads |
Attached is a test to make sure that update() throws out its data so it
can be lazily reloaded from the database. This is in case the database
alters the data on update, like with a trigger.
I did this as part of testing DBIx::Class::CDBICompat. CDBICompat
contains many more small additional functionality tests like this to
make CDBICompat work just like CDBI.
Subject: | lazy_update.patch |
--- t/04-lazy.t (revision 54551)
+++ t/04-lazy.t (local)
@@ -7,7 +7,7 @@
BEGIN {
eval "use DBD::SQLite";
- plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 25);
+ plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 27);
}
INIT {
@@ -76,3 +76,25 @@
};
ok($@, $@);
+
+# Test that update() throws out columns that changed
+{
+ my $l = Lazy->create({
+ this => 99,
+ that => 2,
+ oop => 3,
+ opop => 4,
+ });
+
+ $l->oop(32);
+ $l->update;
+
+ ok $l->db_Main->do(qq{
+ UPDATE @{[ $l->table ]}
+ SET oop = ?
+ WHERE this = ?
+ }, undef, 23, $l->this);
+
+ is $l->oop, 23;
+}
+