-
Notifications
You must be signed in to change notification settings - Fork 248
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
Accept pqxx::binary
concept in more places.
#936
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This type has been deprecated since 7.2.0, more than 4 years ago.
This was a long-forgotten feature that somebody thought might be a good idea, around 20 years ago. It's only been deprecated for a short time, but it's so obscure that I stronly doubt that anyone has ever used it at all. Meanwhile it was weighing down a pretty basic piece of code that comes up in lots of loops, so... less is more.
This has been deprecated for the entire 7.x cycle.
Use `pqxx::connection::encrypt_password()` instead.
Use `pqxx::params` instead.
Use the factory functions instead.
Use `unesc_bin()` and `quote(bytes_view)` instead.
These constructors have been documented as "do not use" in various ways for a long time. More generally, I'm settling on a deprecation horizon of 3 years. It's been so long since 7.0 came out that it's just not reasonable to keep everything that was deprecated since then. Instead, I'm now retiring things that were deprecated in 7.6.
Not clear why those were there in the first place.
* Retire `binarystring`. This type has been deprecated since 7.2.0, more than 4 years ago. * String conversion to `string_view`. More binary types. Fixes: #694 Fixes: #827 Making much broader use of concepts. String conversions now accept any contiguous range of `std::byte` as binary data. Traits specialisations for integer and floating-point types are simpler now. And you can now just convert from string to `std::string_view` (or `char const *`), so long as you don't access it after the original string's lifetime ends. * Work around Visual Studio 2022 concepts problem. This compiler was having trouble with the syntax I used to specialise the generic `string_traits<T>` template to a _concept_ `T` (as opposed to run-of-the-mill specialisation to a _type_ `T`). So just for the floating-point string traits, I went back to the old setup where I had a separate implementation type template (`string_float_traits`) and derived the `string_traits` implementations for those types from instantiations of that template. * Forbid string conversion from `char const *`. It was stupid of me to allow this. I hope nobody ever used it.
Not sure how useful this is, but it's definitely more intuitive. Theoretically we might be able to leave `nullness::is_null()` on such types unimplemented altogether, though that might make things a little too irregular.
Fixes: #925 Extends a bunch more functions that accept `pqxx::bytes_view` with variants which accept any type that satisfies the `pqxx::binary` concept. Also, change the `pqxx::bytes_view` type alies from being a `std::basic_string_view<std::byte>` (which doesn't actually have to work according to the standard!) to being a `std::span<std::byte>`. This seems to be broadly compatible with existing code. For completeness I'm adding a `pqxx::writable_bytes_view` as well. Along the way I'm assuming support for C++17's `std::filesystem::path`, and adding a conversion to `pqxx::zview`. With that, `pqxx::blob` no longer needs explicit support for `std::filesystem::path` filenames; it just accepts `pqxx::zview` and passing a `std::filesystem::path` will just work. It avoids some ambiguities.
Oops, I wanted to merge this into the start-8 branch. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #925
Extends a bunch more functions that accept
pqxx::bytes_view
withvariants which accept any type that satisfies the
pqxx::binary
concept.
Also, change the
pqxx::bytes_view
type alies from being astd::basic_string_view<std::byte>
(which doesn't actually have to workaccording to the standard!) to being a
std::span<std::byte>
. Thisseems to be broadly compatible with existing code. For completeness I'm
adding a
pqxx::writable_bytes_view
as well.Along the way I'm assuming support for C++17's
std::filesystem::path
,and adding a conversion to
pqxx::zview
. With that,pqxx::blob
nolonger needs explicit support for
std::filesystem::path
filenames; itjust accepts
pqxx::zview
and passing astd::filesystem::path
willjust work. It avoids some ambiguities.