Commit Graph

57 Commits

Author SHA1 Message Date
Vadim Zeitlin
547a62eec1 Add fmt library as submodule and use it in the tests
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.
2026-01-14 23:40:06 +01:00
Vadim Zeitlin
f7a1a05913 Use nullptr instead of NULL or 0
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.
2026-01-14 14:24:39 +01:00
Vadim Zeitlin
143f302bb2 Remove insignificant trailing whitespace from source files
No real changes.
2025-08-13 18:07:15 +02:00
Vadim Zeitlin
c35b1b6a77 Avoid disabling MSVC CRT security warnings globally
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.
2025-06-08 02:49:21 +02:00
Vadim Zeitlin
20325f57c9 Add unit test to check loading backends dynamically
Ensure that loading backend dynamically, i.e. using their name, works.

This required adding a way to get this name from the test context.

See #1250.
2025-05-17 00:33:31 +02:00
Vadim Zeitlin
fb04446e35 Convert most HTTP links to HTTPS
No real changes, but it's not very serious to use HTTP links in 2025.
2025-03-04 18:03:53 +01:00
Vadim Zeitlin
5e9f200001 Read entire Oracle CLOB and not just its length in characters
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.
2024-11-20 00:35:15 +01:00
Vadim Zeitlin
2b9afba3f5 Make procedure_creator_base helper more flexible and rename it
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).
2024-11-19 23:29:46 +01:00
Vadim Zeitlin
d089386a18 Move table creator helpers to the start of Oracle test
No real changes, just make it possible to use these helpers in the unit
test to be added.

This commit is best viewed using Git --color-moved option.
2024-11-19 23:28:40 +01:00
Vadim Zeitlin
e92e6d1dae Fix Oracle XML tests with non-ancient Oracle versions
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.
2024-11-09 23:35:59 +01:00
Vadim Zeitlin
bf840edf79 Remove stray debug output from Oracle unit test
Don't spam stdout with buffers values.
2024-11-09 17:51:00 +01:00
Vadim Zeitlin
0aa2c1f27b Get rid of "soci_use_common_tests" hack
This can be avoided by using a different base test context class for the
non-empty tests.
2024-11-06 14:54:37 +01:00
Vadim Zeitlin
b0ecbca57a Extract common tests in soci_tests_common library
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.
2024-10-23 13:54:01 +02:00
Vadim Zeitlin
43cc67276b Move procedure_creator_base to Oracle test
This class is only used there, so don't define it in the common header.
2024-10-23 00:39:36 +02:00
Vadim Zeitlin
b2172e4ac6 Replace remaining occurrences of sprintf() with snprintf()
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.
2024-08-19 14:19:03 +02:00
JaroslawCendrowski
8a5ed87317 Fix conversion of dates before 1900 in Oracle backend
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.
2024-04-01 01:15:42 +02:00
Robert Adam
be4677149e Address review comments 2024-01-16 20:45:30 +01:00
Robert Adam
47d9068366 Special case data type for Oracle backend 2024-01-13 17:09:31 +01:00
Robert Adam
ae75990cb2 finalize common blob test & remove backend-specific ones 2024-01-13 16:46:31 +01:00
Robert Adam
68033e037a Start implementing shared BLOB tests 2024-01-13 16:46:31 +01:00
Robert Adam
4eec33acf2 Oracle: Extend test cases 2024-01-13 16:46:31 +01:00
Robert Adam
047b74915b Oracle: Streamline BLOB interface
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).
2024-01-13 16:46:31 +01:00
Vadim Zeitlin
07cb45e4a1 Merge branch 'master' into data_types 2024-01-03 00:43:58 +01:00
Stefan van Kessel
74005b5a60 Forbid passing temporaries to soci::use()
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.
2023-10-20 01:43:06 +02:00
Lukas Zanner
367c0c0341 Revert unnecessary changes in unit tests 2023-08-13 17:25:30 +02:00
Lukas Zanner
0a8f4501b3 Update unit tests of Oracle backend for complete integer type support 2023-08-13 17:25:27 +02:00
Vadim Zeitlin
6d5fd5a79f Upgrade CATCH header to v2
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.
2022-12-25 23:27:51 +01:00
Robert Adam
2d37f99530 BLOB: Make [read|write]_from_start the default impl
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.
2022-09-22 19:57:02 +02:00
Vadim Zeitlin
04c3daf8c3 Drop SOCI_OVERRIDE and use override keyword directly
We don't need the macro any longer now that we use C++14.
2022-09-18 17:28:57 +02:00
gaocheng3
3d0edf59ba Fix working with default Oracle NUMBER using rowset API
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>
2021-04-18 18:31:22 +02:00
Vadim Zeitlin
9c2e048bf9 Check that ORACLE_HOME is set in Oracle test
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.
2021-03-19 02:49:54 +01:00
Vadim Zeitlin
a76f7b996d Account for Oracle empty/null strings confusion in the tests
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.
2021-03-11 22:58:29 +01:00
Frantisek Comorek
a0c54e9ed4 Fix gcc 8 -Wcatch-value in the Oracle test too
This is similar to fcd1eec279 which didn't
cover the Oracle-specific tests.

Closes https://github.com/SOCI/soci/pull/680
2018-09-17 13:53:49 +02:00
Heiko Rabe
d5e2dff0bc Add explicit "soci::" qualifier to Oracle testcase (#653)
Fix Oracle backend compilation under macOS by using explicit "soci::session".

Closes #652.
2018-06-10 23:06:27 +02:00
Mateusz Loskot
05ab0bcf6d Add SOCI_OVERRIDE macro as conditional C++11 override specifier
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
2017-09-24 23:05:06 +02:00
Vadim Zeitlin
b85ec90c65 Check that inserting malformed XML values fails
Skip this test for Firebird which doesn't have real XML support.
2017-09-15 17:31:04 +02:00
Vadim Zeitlin
bd236c8c8e Merge branch 'xml-firebird'
Closes #578.
2017-09-15 00:32:12 +02:00
Vadim Zeitlin
63bcc89440 Add workaround for empty strings being null in Oracle
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.
2017-09-14 15:03:45 +02:00
Vadim Zeitlin
85159db6f9 Refactor: move XML and CLOB tests to common code
Don't duplicate them for PostgreSQL and Oracle, especially because they
will be needed for other backends in the future too.
2017-09-13 15:09:35 +02:00
Vadim Zeitlin
c6aef12b1e Add test checking string length when using bulk insert
This used to be broken, so add a test to check that it works after the
changes of the last commit and to avoid breaking it again.
2017-07-22 01:18:03 +02:00
Maciej Sobczak
6eb1a3e977 Fixed handling of empty long strings. 2016-10-22 22:10:46 +02:00
Maciej Sobczak
e7194837e5 Added empty_blob() and nvl() to portable utilities. 2016-10-17 22:12:37 +02:00
Maciej Sobczak
45eaff9e98 Added handling of big string in DDL. 2016-10-14 22:19:50 +02:00
Maciej Sobczak
1655a195ee Added bigstring (XML and CLOB) support. 2016-10-10 22:58:26 +02:00
Maciej Sobczak
4b0dbab3e4 Added uniform offset for BLOB read/write operations. 2016-10-01 22:20:08 +02:00
Maciej Sobczak
8d29016756 Added unit tests and docs for bulk iterators. 2016-07-07 22:05:50 +02:00
Maciej Sobczak
c959c38128 Added Oracle unit tests for DDL and metadata. 2016-06-27 22:31:35 +02:00
Miha Ravselj
b5d65076f6 - oracle cmake Windows fix
- test oracle compilation error fix
2015-07-11 00:15:27 +02:00
Benjamin Blundell
ffbfdc0ef5 Inlined the pragmas for the C++11 tests 2015-05-22 14:46:36 +01:00
Mateusz Loskot
7d7516d417 Add more qualifications uses of session class with namespace soci::session.
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
2015-05-19 21:00:54 +02:00