[odb-users] queries during results iterations

Adnan RIHAN axel50397 at gmail.com
Mon Apr 20 12:52:52 EDT 2015


Hi Boris,

On 20 avril 2015 at 15:57:05, Boris Kolpackov (boris at codesynthesis.com(mailto:boris at codesynthesis.com)) wrote:

> > odb::transaction t(this->m_db->begin(), !odb::transaction::has_current());
> After all,
> you need the above "start a transaction and make it current unless
> one is already in progress" hack for some reason...

Actually, it’s exactly for this issue. In the beginning, I only had:
odb::transaction t(this->m_db->begin())
[...]
t.commit();

But the callback would call the same function the transaction is in, and obviously I can begin 2 transactions at the same time in the same thread right?

The only other way to check that would be to make a separated query/query_one in the callback, to be sure to avoid trying to create another transaction, while correctly closing the right one and not « current ».

Now, writing this email, I realized that « odb::transaction::current().commit(); » is closing the current transaction, opened by findOne() and NOT REOPENED in the callback. I’ll add a boolean and come back to tell you if I’m failing so much I must relearn how to code...
--  
Cordialement, Adnan RIHAN.

GPG: 5675-62BA (https://keybase.io/max13/key.asc)
-> Si vous n'utilisez pas GPG mais souhaitez quand même m’envoyer un e-mail chiffré: (https://encrypt.to/0x567562BA).



More information about the odb-users mailing list