Skip Menu |

This queue is for tickets about the Class-DBI CPAN distribution.

Report information
The Basics
Id: 33503
Status: new
Priority: 0/
Queue: Class-DBI

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



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; +} +