Emulate that CDBI throws out all changed columns and reloads them on
[dbsrgits/DBIx-Class.git] / t / cdbi-t / 04-lazy.t
index 9db9e27..5fd18f2 100644 (file)
@@ -1,13 +1,19 @@
 use strict;
 use Test::More;
 
+
 #----------------------------------------------------------------------
 # Test lazy loading
 #----------------------------------------------------------------------
 
 BEGIN {
+  eval "use DBIx::Class::CDBICompat;";
+  if ($@) {
+    plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
+    next;
+  }
        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 {
@@ -73,3 +79,24 @@ eval {    # Multiple false columns
 };
 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;
+}