-
Notifications
You must be signed in to change notification settings - Fork 244
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
row::to should support optional<string_view> #694
Comments
Thanks for finding that. I think I'll have to look into some ways to reduce the redundancy between those places in the code. |
@alexolog I'm slowly coming around to the view that perhaps libpqxx should just allow you to convert a field to, say, a That would simplify the code inside libpqxx, and allow applications a bit more freedom to optimise their memory management. The cost: more responsibility to be aware of the data's lifetimes. Thoughts? |
As long as pqxx::row holds the result internally |
It's |
I assume that
|
Yes and no, respectively. Yes, the But in this |
So I haven't checked the documentation very closely, but it would be a good idea to warn about such usage because it looks like the row is returned by value. |
There has been no activity on this ticket. Consider closing it. |
There has been no activity on this ticket. Consider closing it. |
There has been no activity on this ticket. Consider closing it. |
I do still intend to fix this one... But it's a pretty radical change to allow general conversion to |
There has been no activity on this ticket. Consider closing it. |
There has been no activity on this ticket. Consider closing it. |
There has been no activity on this ticket. Consider closing it. |
I just tripped on something related to this. pqxx::transaction_base::query<> allows std::string_view, but not std::optionalstd::string_view. |
@jlittlenz converting to However in libpqxx 8.0 I'm thinking to make this the caller's problem. You would be able to "convert" any string to a |
Thank you. My "trip" was partly due to my expectations of the field::view method; null values were tripping everything, but not field::view. It just gives an empty string, and one can use field::is_null if you care about it. |
Right, @jlittlenz. Generally you should check for nullness before trying to read a value. Although I did just notice that nowadays you are guaranteed to get an empty string when the value is null. That was not the case when I first wrote libpqxx, but it is the case in all supported versions now. So it may be time to review the design for that. Converting a null to any type is unsupported, but for some types it may be reasonable to accept an empty string as a null. Think |
For future reference: I just checked and the documentation for |
There has been no activity on this ticket. Consider closing it. |
Yes, this has been on the shelf for a long time... Life has distracted me to some degree. |
template<typename Tuple> void row::to(Tuple &t) const
supportsstd::optional<std::string>
as a tuple type, but notstd::optional<std::string_view>
. Please fix.The text was updated successfully, but these errors were encountered: