taocpp / taopq

C++ client library for PostgreSQL
Boost Software License 1.0
265 stars 40 forks source link

What are the template arguments for transaction? #34

Closed emmenlau closed 3 years ago

emmenlau commented 3 years ago

I've just updated to latest master branch, and found that the following code does not compile anymore:

std::shared_ptr<tao::pq::transaction> = conn->transaction();

It seems that the transaction class now uses template arguments. I've checked the docs, but its not explicitly mentioned, and in the code I find now mostly this kind of usage: const auto tr = conn->transaction();.

Could you kindly help what the template arguments for transaction are?

d-frey commented 3 years ago

That depends on what traits you are using. In general there are now the following class templates and type aliases:

This is a result of implementing #18. The preferred style of using transactions (and mostly everything else) is therefore, as you noticed, simply using auto.

Also note that the above, e.g. the recent changes, only affect the handling of the parameters. There are currently no traits for treating the results in similar ways. This is even more work and there are a few problem due to the libqp API and I currently have no time to work on that. And yes, I need to update the documentation.

d-frey commented 3 years ago

For future reference: The changes I described in my previous comment have been reverted. Please refer to the documentation for a proper description of the API.