From 179eb696191958bae891916eec2708c4d3e34983 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 2 Sep 2013 09:22:39 +0200 Subject: Fix UPDATE statement for smart containers with read-only value members Here we have to include them (think what happens when we erase an element somewhere in the middle of a container). --- common/container/change-tracking/test.hxx | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'common/container/change-tracking/test.hxx') diff --git a/common/container/change-tracking/test.hxx b/common/container/change-tracking/test.hxx index 6281322..edbff0a 100644 --- a/common/container/change-tracking/test.hxx +++ b/common/container/change-tracking/test.hxx @@ -78,4 +78,37 @@ struct inv_object2 odb::vector o1; }; +// Test read-only values (we still need to include them in the UPDATE +// statement). +// +#pragma db value +struct ro_value +{ + ro_value (int i_ = 0, int j_ = 0): i (i_), j (j_) {} + + #pragma db readonly + int i; + + #pragma db readonly + int j; +}; + +inline bool +operator== (const ro_value& x, const ro_value& y) +{ + return x.i == y.i && x.j == y.j; +} + +#pragma db object +struct ro_object +{ + ro_object () {} + ro_object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector v; +}; + #endif // TEST_HXX -- cgit v1.1