SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.37k stars 472 forks source link

Add automatic widening conversions in dynamic bindings #1097

Closed Sildra closed 5 months ago

Sildra commented 8 months ago

Add the ability to perform lossless conversions in the dynamic bindings. Also add an opt-in narrowing cast with the define SOCI_WIDENING_CASTS (to be discussed).

Allow for extending the range of casts with the templated struct soci::soci_cast with the model of soci::type_conversion<T>.

Sildra commented 8 months ago

int64_t and long long are the same under Windows and different under linux. I will either need to wait for #954 or temporarily switch to old types for the build to pass.

Sildra commented 8 months ago

I will need to add support for a c++98 version of the metaprog templates and check if adding constexpr to the get function avoids the weird unreachable code on the statements. I can't seems to reproduce both of those issues under VS2022.

vadz commented 8 months ago

You can base this PR on #954 if it makes things simpler.

As for the unreachable code warnings (do you have a direct link?), they can be suppressed explicitly if nothing else works.

Sildra commented 8 months ago

Only the Windows builds are missing :

I will also add tests in common to check the feature.

Edit: the pre-c++11 std::numeric_limits<T> don't have a constexpr evaluation for min/max and can't participate to template resolution. I will relax template def for pre-c++11 and switch to runtime checks. I might tell the windows compiler to use the templates post-c++11 even in std=c++98 if the compiler has the possibility.

vadz commented 5 months ago

I don't think this change is compatible (semantically and not just syntactically) with the now merged #954, so I think it should probably be closed -- but please let me know if I'm missing something.

Sildra commented 5 months ago

I will check the changes proposed by the new types.