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.
We need to read the entire contents of the CLOB in Oracle backend and
not just the number of bytes corresponding to its length in characters
as returned by OCILobGetLength() because this may (and will) be strictly
less than its full size in bytes for any encoding using multiple bytes
per character, such as the de facto standard UTF-8.
Also make reading CLOBs more efficient by doing what Oracle
documentation suggests and using the LOB chunk size for reading.
Finally, add a unit test checking that using non-ASCII strings in UTF-8
(which had to be enabled for the CI) with CLOBs does work.
This commit is best viewed ignoring whitespace-only changes.
This will allow to use it for creating functions as well as procedures
(and also procedures with a name other than "soci_test" if this is ever
needed).
Although the test passed with Oracle 11 used in the CI job, it fails
with both (old) Oracle 18 and latest Oracle 23 because using xmltype()
with null values doesn't work.
Avoid doing it by testing for null explicitly in the test.
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.
This (unsafe) function is deprecated in macOS 12 SDK and using it
results in the warnings that are not worth suppressing -- instead, just
stop using it and always use snprintf(), even when we know that we can't
overflow the buffer.
Oracle stores dates in a weird "excess-100" format, quoting
documentation for the "external 2024-04-01 type":
| The century and year bytes (bytes 1 and 2) are in excess-100 notation.
| The first byte stores the value of the year, which is 1992, as an
| integer, divided by 100, giving 119 in excess-100 notation. The second
| byte stores year modulo 100, giving 192.
Fix our code to compute the year value correctly for the years before
1900, which were previously off by 100 years.
Also add a test checking that this works correctly now by round tripping
all dates from second to twenty-second century to the database.
Closes#1135.
Closes#1136.
This commit adapts the oracle BLOB interface such that it now is en par
with the implementations for the other backends. Notably this means that
it is now possible to perform read and write operations on a
default-constructed soci::blob object and then insert this object into
the database at a later point (instead of first having to select the
BLOB out of the database, before being able to access it).
Previously code doing this compiled but resulted in undefined behaviour
due to using variable memory after destroying it, so explicitly prevent
it from compiling now to avoid run-time problems later.
Document this incompatible change and update the change log for the next
release.
Closes#1070.
Closes#1071.
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.
Using rowset API with the result of to_number(), which returned a NUMBER
with both precision and scale of 0 (indicating that it's the default
NUMBER type, i.e. NUMBER(38, 10)), previously resulted in 'ORA-01455:
converting column overflows integer datatype' error because we
incorrectly handled such numbers as integers rather than doubles that
they really are.
Closes#872.
See #874, #875.
Co-Authored-By: Vadim Zeitlin <vz-soci@zeitlins.org>
Not setting it results in cryptic "Cannot create environment" errors
later for all the tests, so it is better to avoid running them at all in
this case.
Oracle doesn't distinguish between empty and null strings, so we can't
rely on the indicator being set correctly.
Provide a way to test for this for the tests that want to test for the
difference between empty and null strings when using the other backends.
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.
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