
Am 07.09.25 um 22:57 schrieb Maximilian Riemensberger via Boost:
* Transaction scoping rules: The scoping rules around transations, statements and resultset are suprising. The following example demonstrates that:
``` { sqlite::transaction t{conn}; // use a transaction to speed this up
auto st1 = conn.prepare(R"(insert into libitems (length, content_type) values ($length, $content_type) returning id)");
auto st2 = conn.prepare(R"(insert into libpaths (path, libitem) values ($path, $libitem))");
//{ // uncomment this scope to make it work auto res = st1.execute<rowid>({{"length", 123}, {"content_type", "application/octet-stream"}});
rowid id = res.current();
st2.execute({{"path", "lib/path/to/file"}, {"libitem", id.id}}); //}
t.commit(); } ```
The requirement of this extra scope around the resultset was quite surprising to me. Nowhere in the library documentation is this behavior explained.
I fully agree: To the user this certainly is surprising and I don't see how this can be easily explained. Is there anything in the wrapper to make this usable in an intuitive way?