diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-18 11:38:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-18 11:38:40 +0200 |
commit | 458296a902060900487f80219a8762142bb7800e (patch) | |
tree | 2c6a0bfb63e9d2dcb9c11774b157ef443cbb43bb /common/callback/test.hxx | |
parent | 839a84b996d89dcf3d553af23e4ed5e0e4fa60e2 (diff) |
Fix custom recursive loading in post_load callback
Before we called the callback while holding the statements locked. As a
result, if the callback tried to load another object of this type, it
failed. Now we unlock the statements (since we have completely loaded
the object from ODB's point of view) and then call the callback. The
callback test has been updated to test this situation.
Diffstat (limited to 'common/callback/test.hxx')
-rw-r--r-- | common/callback/test.hxx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/common/callback/test.hxx b/common/callback/test.hxx index 274e2b5..058a327 100644 --- a/common/callback/test.hxx +++ b/common/callback/test.hxx @@ -12,8 +12,15 @@ #pragma db object callback(db_callback) struct object { - object (unsigned long id, unsigned long d): id_ (id), data (d), pobj (0) {} - object (): id_ (0) {}; + object (unsigned long id, unsigned long d) + : id_ (id), data (d), pobj (0), robj (0), ref (0) + { + } + + object () + : id_ (0), pobj (0), robj (0) + { + } #pragma db id unsigned long id_; @@ -22,6 +29,12 @@ struct object object* pobj; + // Test custom recursive loading. + // + #pragma db transient + object* robj; + unsigned long ref; // Unless 0, reference to another object. + void db_callback (odb::callback_event, odb::database&); |