Commit Graph

72 Commits

Author SHA1 Message Date
Vadim Zeitlin cf3e73ed3c Add get_error_category() test to PostgreSQL tests
Use this function in at least one of the tests to check that it's not
totally broken.
2025-04-22 17:05:29 +02:00
Vadim Zeitlin cbb28ed046 Use CHECK_THAT() in PostgreSQL unit tests
This is simpler than manually using strncmp() or string::find().

Omit one negative test, it's not clear what was it actually testing for.
2025-04-22 17:02:01 +02:00
Robert Adam caaf5627a1 Support single-quotes for parsing connection strings
Fixes #1210.
2025-03-05 00:45:23 +01: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
Robert Adam 41071bff8d Adapt test executable names 2025-02-22 17:37:10 +01:00
Robert Adam 2769d0b7f2 Remove last remaining bare Makefiles 2025-02-02 10:10:48 +01:00
Robert Adam 249ddbd91d Remove redundant (unused) test files 2025-02-02 09:22:53 +01:00
Robert Adam c88da3b62c Merge remote-tracking branch 'upstream/master' into revamp-cmake 2025-01-03 16:05:52 +01:00
Vadim Zeitlin 1a6607bc2f Remove manual connection string parsing from PostgreSQL backend
Use connection_parameters instead for simplicity and correctness: this
fixes the equivalent of #1175 in this backend too.
2024-11-09 22:37:13 +01:00
Vadim Zeitlin 9e2faf4526 Correct example of PostgreSQL connection string
Use something in valid PostgreSQL syntax, i.e. space, and not semicolon,
separated and using "dbname" instead of "database".
2024-11-09 22:37:13 +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 55f3988382 Remove function_creator_base
This class seems to be completely useless, it's used by function_creator
in PostgreSQL test only, so just inline it there.
2024-10-23 00:40:08 +02:00
Carsten Stiborg 8863ff9cae Allow backends to register the schema when working with metadata
Define the API and implement it for PostgreSQL and MySQL.

Closes #1156.
2024-10-10 18:23:13 +02:00
Robert Adam 5150a5191a Get rid of deprecated Makefiles 2024-08-31 16:24:38 +02:00
Robert Adam dd5e3dd972 Build shared and static libs separately 2024-08-31 16:24:36 +02:00
Robert Adam bb86d445f4 Add options to configure test connection strings 2024-08-31 16:22:13 +02:00
Robert Adam 456a8cc6ae Include building tests 2024-08-31 16:22:13 +02:00
Lukas Zanner ae07cd546e Add automatic type conversion to row::get()
Convert to the requested type if lossless conversion is possible to make
the behaviour more compatible with the previous SOCI versions and more
useful.

See #1127.
2024-03-27 15:46:30 +01: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 7fa93e8586 BLOB: Add default-constructed read tests 2024-01-13 16:46:31 +01:00
Robert Adam 2f330d48c0 Revamp Postgresql BLOB implementation
This commit refactors the existing implementation to factor out common
code into dedicated functions.

Furthermore, this commit adds support for creating new BLOBs via the
soci::blob interface by writing to a default-constructed soci::blob
object. The created BLOB will be deleted again, unless it is inserted
into a database, in which case the lifetime of the created BLOB gets
extended indefinitely (or rather to the point at which the database
decides to destroy it).

Thus, it is now possible to use the soci::blob type to insert new BLOBs
in a Postgresql table.

Note: Attempting to insert a default-constructed soci::blob into a
database will also create a new BLOB object at the point at which Soci
decides to really perform the insert (after checking, e.g. passed
indicators).
2024-01-13 16:44:57 +01:00
Robert Adam 843e19051f Postgresql: Implement support for BLOB trimming 2024-01-13 16:44:57 +01:00
Lukas Zanner 826fa7753a Expose new db_type for dynamic type mapping 2023-08-13 17:26:15 +02:00
Lukas Zanner 4de379f178 Fix Postgres unit test 2023-08-13 17:25:33 +02:00
Lukas Zanner 4c36213928 Remove unsigned type support checks in unit tests
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.
2023-08-13 17:25:32 +02:00
Lukas Zanner a824ac8502 Fix incorrect extraction of Postgres bool type
bool values occupy 1 byte of storage in Postgres, so we might as well
extract it as 1 byte instead of 4.
2023-08-13 17:25:31 +02:00
Lukas Zanner 367c0c0341 Revert unnecessary changes in unit tests 2023-08-13 17:25:30 +02:00
Lukas Zanner 236966f292 Update unit tests of PostgreSQL backend for complete integer type
support
2023-08-13 17:25:26 +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
parvit (Vittorio Parrella) 33395699b4 Fix PostgreSQL enum types support when using soci::row
Recognize enums when dealing with unknown types and handle them as
strings.

See #1026.
2022-12-25 23:19:49 +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
Vadim Zeitlin 721bb1aa9d Remove trailing whitespace from all files
No real changes.
2021-04-07 19:32:41 +02:00
Vadim Zeitlin b9594bbec7 Don't run OID PostgreSQL test if OIDs are not supported
They've been deprecated for some time and support for "with oids" was
removed in PostgreSQL 12 and so creating the table used in this test
just fails.
2021-03-19 19:08:21 +01:00
kuvaldini c1083ec8f2 Fix PostgreSQL tests compilation under macOS yet again
Avoid another ambiguity error between soci::session and session defined
in the system headers.

Closes #864.

Signed-off-by: kuvaldini <ivan@kuvaldini.pro>
2021-03-19 14:09:50 +01:00
Vadim Zeitlin d28d6827a9 Fix a number of variable shadowing warnings from MSVS
Don't redefine the same variables in a couple of tests.

In other places, use artificially different names to avoid clashes with
the existing variables in outer scope.

No real changes.
2021-03-12 02:18:02 +01:00
Vadim Zeitlin ae5d5c4460 Fix harmless unused variable warning in PostgreSQL test
Just don't name the exception variable.
2021-03-12 02:16:45 +01:00
Mariana Meireles 0e69973d64 Use fully qualified type for session in PostgreSQL test
This is similar to 88e7249f (Fix PostgreSQL tests build under macOS,
2020-10-30).

Closes #841.
2020-12-08 15:59:24 +01:00
Christian Kröhnert 7ee01afc4c Fix use of quoted identifiers with colons in PostgreSQL queries
This was broken by 99d26063 (Fix handling of identifiers with colons in
PostgreSQL backend, 2020-01-27), see #782.

Fix this and add a test checking for the use of such identifiers.

Closes #840.
2020-12-03 16:15:57 +01:00
Noah Shutty 88e7249f4c Fix PostgreSQL tests build under macOS
Use fully qualified "soci::session" type name to avoid conflicts with
"session" struct declared in sys/proc.h under macOS.

This is a recurrent problem (see #605 for a previous example of it)
which should probably be solved by removing "using namespace soci" from
the test to prevent it from happening again.

Closes #832.
2020-10-31 13:36:53 +01:00
Rommel Trindade 99d2606375 Fix handling of identifiers with colons in PostgreSQL backend
Colon inside identifiers was still interpreted specially by SOCI, even
when they were quoted.

Fix this by suppressing the colon special meaning inside quotes.

Closes https://github.com/SOCI/soci/pull/782
2020-01-30 23:13:43 +01:00
Vadim Zeitlin fcd1eec279 Avoid g++-8 -Wcatch-value warnings in the tests
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.
2018-05-20 16:04:22 +02:00
Mateusz Loskot 95e4633a5f Drop support for PostgreSQL 7.x
Remove uses of CMake opions and related #define-s
  SOCI_POSTGRESQL_NOPREPARE
  SOCI_POSTGRESQL_NOPARAMS
  SOCI_POSTGRESQL_NOBINDBYNAME.

Closes #122
2018-02-26 18:09:33 +01:00
Vaughn Draughon e8ed51c377 use fully qualified soci::session to fix build on macosx sierra 2017-10-21 13:23:47 -06: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