-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PQXX_DECLARE_ENUM_CONVERSION issues #807
Comments
The conversion from Lines 253 to 256 in 9d2a459
libpqxx/include/pqxx/field.hxx Lines 527 to 544 in 9d2a459
libpqxx/include/pqxx/strconv.hxx Lines 402 to 420 in 9d2a459
This is the problem caused by 613f068. I think we should change it to |
Apparently |
Yes, |
Can you fix it? |
I would like to leave it to @jtv, as I cannot determine which of the following two methods would be better (less impact on the API) to fix.
|
Thanks @tt4g! I seem to have a nasty 'flu at the moment so I'm not at my best, and your analysis helps a ton. First thought is perhaps we can make it so we can get a But it's still strange to me that this does not happen in testing. I regularly build and test against C++17, C++20, and C++23! @alexolog, for completeness, could you show me a minimal reproduction of the problem? In other words, the absolute minimal stand-alone code that displays the problem? I think maybe it's that I wrote tests for enum conversions before I had streaming queries. Streaming queries are the only case where we call |
I now suspect that I will need to split |
It will take a bit since we use a framework that wraps pqxx and I haven't used it directly in a while. I'll whip something up when I have a bit of spare time. |
Thanks. Meanwhile yes, a switch to There's a bit of a conundrum there with minimising string copies but let's be honest - exceptions are not what we optimise for. If we wanted it really nice we could create a |
Minimal sample:
Compilation Errors:
|
Every time I get back into this issue, something distracts me. :-( Haven't forgotten about it, but various loved ones getting hit with various medical issues and such. |
@alexolog, @tt4g — I finally made some time to focus on this and really, it seems pretty easy. I added a specialisation for And for a free bonus I used |
Fixes #807. Type names for user-defined enums are stored as `std::string_view`, not as `std::string` like the others. (Both are `inline` though.) The problem did not affect the conversion as such, and that is why a pure unit test was not enough to catch it. But it did show up when converting a `pqxx::field` value.
Can I just drop the header in or do I have to rebuild the library? |
You'll need to rebuild the library. But if you still have your build directory, you could just drop the files I changed into your source tree, recompile, and reinstall. No need to rerun the configure step if you don't want to. |
Fixes #807. Type names for user-defined enums are stored as `std::string_view`, not as `std::string` like the others. (Both are `inline` though.) The problem did not affect the conversion as such, and that is why a pure unit test was not enough to catch it. But it did show up when converting a `pqxx::field` value.
When I define an enum
enum class MyEnum : int16_t { a, b, c }; // smallint
Then declare
namespace pqxx { PQXX_DECLARE_ENUM_CONVERSION(MyEnum); }
And try to use it in a tuple, I get the following error when converting a
row
to the tuple:The text was updated successfully, but these errors were encountered: