Replace existing use of std::cout and std::cerr with fmt::print[ln]():
this is simpler and more convenient and also faster to compile.
Also configure all CI jobs to clone submodules, as fmt submodule is
required now.
Run clang-tidy modernize-use-nullptr check on all files and manually
change the remaining NULLs skipped by it to nullptr.
Also use nullptr in the documentation.
Use "_s" versions of the standard C functions if possible/simple to do
and disable deprecation warnings explicitly in a couple of places where
this could not be done instead of disabling them globally.
Also stop using strcpy() entirely and use strncpy() instead.
See #1268.
This allows to compile them once, instead of doing it for every backend:
while this doesn't matter for the CI builds, recompiling common-tests.h
a dozen times enormously slowed down local builds using all backends.
Now it is compiled only once, as test-common.cpp, and all the other
tests (except for the "empty" one) just link with the resulting library.
Also extract some parts of this file into separate headers, that can be
included only by the tests that actually need them.
Note that the entire test-common.cpp probably ought to be split into
multiple files, to speed up its build too, but this can be done later.
Despite previously assumed and tested, most of the databases support
storing the various unsigned integer values. The checks for it in the
tests are therefore obsolete.
Only Firebird and SQLite seem to have a problem with storing UINT64_MAX.
The retrieval of it in a sorted result set with multiple other values
shows that the value is stored as a signed integer in the database.
And update all uses of CHECK_THROWS_AS() to not use reference but the
expected exception type itself, as otherwise the code doesn't compile
any longer.
The older read(...) and write(...) function, which take backend-specific
offsets rather than uniformly taken 0-based offsets (as is the case for
the *_from_start(...) functions), are now implemented in terms of their
*_from_start counterpart.
All test cases have been adapted to now prefer using the *_from_start
functions over the old counterparts.
Catch soci_error (and std::bad_cast in one place) by reference rather
than by value to avoid slicing -- even if it doesn't matter in the test
code, it still provokes the new g++-8 warning about it.
See #640.
MSVC++ 1900+ always compile with C++11 mode enabled, so it should be
safe to selectively enable 'override'specifier for internal use.
It does not enable all C++11 features for SOCI and we still compile
with C++11 compilation mode SOCI_CXX_C11=OFF by default.
Refactoring performed with clang-tidy-4.0:
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSOCI_CXX_C11=ON ..
run-clang-tidy.py -clang-tidy-binary -header-filter='.*' \
-checks='-*,modernize-use-modernize' -fix
Oracle historically treats empty VARCHAR[2] column values as nulls, so
we need to adjust the string length unit test to provide indicators when
retrieving the value of a possibly null string and use nvl() to compute
its length to make this test pass when using this backend.
There is no real XML support in Firebird, so handle it in the same way
as CLOB -- this is the best that can be done with this database anyhow
and is much better than not supporting it at all.
Reuse the existing BLOB support, however we now need to allocate a BLOB
inside firebird_standard_use_type_backend objects as, unlike when using
soci::blob objects, we don't have any way to associate backend-specific
data with the parameter otherwise.
This difference between CLOB and BLOB support is not ideal, but there
doesn't seem to be any way to avoid it.
Without an explicit "character set none", the default character set of the
database is used and if it is set to UTF-8 the values are padded incorrectly
resulting in the test failures.
See #356.
Fix warnings by changing the code whenever possible, in particular remove
firebird_rowid_backend class and src/backends/firebird/row-id.cpp file in
which it was defined entirely as it only resulted in "unreachable code"
warnings but was otherwise unused.
Also avoid implicit conversions by either using the correct types or by making
the casts explicit using static_cast<> in places where the casts are really
needed.
Add helpful SOCI_NOT_COPYABLE, SOCI_NOT_ASSIGNABLE and SOCI_UNUSED macros and
use them to suppress the corresponding warnings.
Finally, combine soci-config.h and soci-platform.h in a single file, always
include the latter as the first header and keep the former as a wrapper for
the latter just for compatibility.
Remove the MSVC "#pragma warning(disable: *)" as they are not needed any more.
Closes#355.
This should solve compilation errors on OSX where struct session defined in
global namespace in /usr/include/sys/proc.h conflicts with unqualified uses of
soci::session.
Fixes#340
This should solve compilation errors on OSX where struct session defined in
global namespace in /usr/include/sys/proc.h conflicts with unqualified uses of
soci::session.
Fixes#340
Silently truncating the data to fit into a column is a bad idea, just don't do
this.
Also add a unit test verifying that an exception is indeed thrown if the value
being inserted doesn't fit in the column, except for SQLite where anything
fits and MySQL where it doesn't but just gets silently truncated by the
database by default.
Finally add a helper on_after_ddl() method to the test context class to allow
creating tables in the common test code instead of having to always do it in
RDBMS-specific way, even when the DDL uses completely standard SQL and the
only difference is that Firebird needs a commit after executing it.
Closes#51.
This will only become useful after the upcoming commits which will extend
what() to return more information about the exception, but commit this
separately as there are only trivial changes in this commit: just use
std::string returned by get_error_message() instead of char* returned by
what() in the tests.
"assert" in the name of the directory doesn't make any sense any more as we
don't use asserts in the test code now that we use CATCH.
Also extend the tests description in the README.md.