libpqxx 7.4.0: "Named constructors," table paths, and more.
Named constructors
Some classes were getting too many constructors. Too much overloading makes for a programming minefield. So these classes are now growing factory functions, also known as named constructors.
For these classes, I would like applications to replace this kind of existing code:
pqxx::stream_to mystream(tx, "mytable");
with this new-style code:
auto mystream(pqxx::stream_to(tx, "mytable"));
Actually there's another change in that line; read on below.
Table paths
Sometimes you need to pass a table name to a libpqxx function. The function will often quote and escape that name internally. But what if the table name includes a schema name, and perhaps even a database name? If we quote the whole thing as one string, it will look to the database as a single weird name, with dots in it. What should happen is that libpqxx quotes each portion (database name, schema name, table name) separately, and puts bare dots between them.
To support that, there's a new way of describing table names: table_path
, an alias for std::initializer_list<std::string_view>
. Use this instead of strings to specify table names.
So instead of this:
auto mystream(pqxx::stream_to(tx, "mytable"));
...I would prefer you to write this:
auto mystream(pqxx::stream_to(tx, {"mytable"}));
The difference is that a table path is not just a name, it's a sequence of one, two, or three strings. (The last of those being the table name, of course.)
Which means that you can now also write:
auto mystream(pqxx::stream_to(tx, {"myschema", "mytable"}));
The rest
All major changes:
- Work around Visual Studio 2017 bug with
[[deprecated]]
. (#405, #406) - Work around eternal Windows bug with
max
macro yet again. (#101) - Prepare for C++20
std::ssize()
. - Dropped test12, which didn't add much and tried to read null strings.
- Support string conversion for
std::monostate
. (#409) - Consistent "named constructors" for
stream_to
andstream_from
. - New
table_path
type. - New
connection
methodsquote_table
andquote_columns
. - Lots of deprecated stream constructors.
pqxx::row::swap()
now finally has thedeprecated
attribute.- Finally deprecated a bunch of
field
,row
, andresult
constructors. - Exposed
transaction_focus
marker class.