Commit Graph

69 Commits

Author SHA1 Message Date
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
4ad4333fd8 Merge branch 'win32-libname-abiver'
Restore ABI version use in Windows DLL names.

See #1252.
2025-05-17 15:05:05 +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
ec00b69a71 Amendments to the parent commit, changing SQLite timeout setting
This should have been part of the parent commit but got accidentally
left out.

See #1254.
2025-05-17 00:23:00 +02:00
Vadim Zeitlin
53f5e9c340 Implement get_error_category() in sqlite3_soci_error
Try to classify all the possible SQLite result codes using SOCI
error_category enum.

In particular, this allows to detect connection and permission errors.

Update the unit test to test the error category too.
2025-04-22 16:48:44 +02:00
Vadim Zeitlin
62001b2365 Add sqlite3_soci_error::extended_result()
Allow to get the extended error code from SQLite too.

Add a unit test checking that the new function returns the expected
result.
2025-04-22 16:48:44 +02:00
Vadim Zeitlin
2a121b57c4 Rewrite SQLite unit test to use explicit try/catch
Don't use CHECK_THROWS_WITH(), it's convenient but not very flexible,
while an explicit try/catch will allow us to add more checks on the
exception object in the upcoming commits.
2025-04-22 16:48:44 +02:00
Vadim Zeitlin
c2b3b04432 Check that the error message contains the expected substring
Relax the check, there is no need to verify that the message is exactly
the same, we only want to check that the expected parts are there.
2025-04-22 13:59:49 +02:00
Vadim Zeitlin
3bc032dec4 Add sqlite3_session_backend::libversion() and libversion_number()
Use these functions instead of directly using SQLite3 ones in the test.

This makes no real difference, but allows to provide the implementation
of these functions in SOCI SQLite3 backend itself and so works even when
SQLite3 library is linked statically into this backend and is not linked
into the test.
2025-04-11 01:52:33 +02:00
Robert Adam
77c75a4e85 Make SQLite overwrite exchange type for integers
Since SQLite doesn't have a type system, we have to always be prepared
to select huge numbers, even if the "type" is e.g. int8.
To do that, we overwrite the exchange type (e.g. in row based APIs) to
always be (u)int64 for integers to avoid over-/underflows.

Update the documentation to explain this SQLite peculiarity and add a
test verifying that this behaves as expected.

Fixes #1190.

Closes #1217.
2025-03-24 00:14:00 +01:00
Vadim Zeitlin
1a634431bd Update SQLite3 test after the last commit
This should have been part of the parent commit.
2025-03-05 00:55:48 +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
Vadim Zeitlin
8fe0a20c3f Merge branch 'revamp-cmake' of https://github.com/Krzmbrzl/soci
Rewrite CMake build system to correspond to current best practices.

Fixes #208.
Fixes #394.
Fixes #456.
Fixes #644.
Fixes #843.
Fixes #929.
Fixes #1005.
Fixes #1015.
Fixes #1094.
Fixes #1111.
Fixes #1115.
Fixes #1122.
Fixes #1152.
Fixes #1159.

See #1118.
2025-03-04 17:14:45 +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
Vadim Zeitlin
411bb3c077 Make SetupForeignKeys ctor explicit
No real changes, just a very minor cleanup.
2025-01-30 01:11:42 +01:00
Vadim Zeitlin
6939029dd8 Disallow text in int column in SQLite get_affected_rows() test
The unit test relies on failing to insert "a" into an integer column but
SQLite is perfectly fine with doing this by default, so use an explicit
CHECK constraint to prevent this from succeeding and to make it behave
in the same way as the other databases.
2025-01-29 00:28:05 +01:00
Robert Adam
f9c540821f Merge remote-tracking branch 'upstream/master' into revamp-cmake 2025-01-26 19:03:27 +01:00
Vadim Zeitlin
2a8abbe49f Turn foreign keys on by default for SQLite tests
This makes its behaviour more compatible with the other backends and
will make writing tests relying on FKs working simpler.
2025-01-21 01:50:56 +01:00
Vadim Zeitlin
03a716a688 Don't rely on default pragma foreign_keys value in SQLite tests
SQLite documentation states that it can change in the future and it's
simple enough to turn it off explicitly, so do it.

Also combine 2 very similar tests in a single one and use 2 sections for
them instead.

No real changes.
2025-01-21 01:49:15 +01:00
Robert Adam
c88da3b62c Merge remote-tracking branch 'upstream/master' into revamp-cmake 2025-01-03 16:05:52 +01:00
Vadim Zeitlin
ae2ca287a8 Reuse connection_parameters parsing in SQLite3 backend
Don't duplicate the code for parsing space-separated possibly quoted
words in SQLite3 backend but just use the common function for it too.

Also correct handling of some boolean parameters, where previously
specifying any value, even "0" or "false", would enable it and document
the exact values accepted for them.

Add tests checking that parsing connection string works as expected.
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
33139741b3 Move roundtrip-tests related helpers to SQLite3 test
This is the only place where they're used so far and it doesn't make
sense to compile them many times over when building the tests for the
other backends.

If these helpers are needed in the other backends tests, we should
extract them into their own header and include it as necessary.
2024-10-22 00:41:23 +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
Thibault FRESNET
ce0630b2cd Improve column names to SOCI database types mapping with SQLite3
Use type-appropriate names for the columns, which are still interpreted
in the same way as just "INTEGER" by SQLite3 itself, but can be mapped
back to the suitable types when reading from the database in SOCI.

Closes #1120.
2024-04-24 16:24:40 +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
7fa93e8586 BLOB: Add default-constructed read tests 2024-01-13 16:46:31 +01:00
Robert Adam
e86da4e712 Extend SQLite BLOB tests 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
Thibault FRESNET
1c37a5fe62 Implement prepare_column_descriptions() in SQLite3 backend
Use TABLE_INFO pragma, which can also be used with SELECT, to get the
information about the table columns.

Closes #1079.
2023-10-20 01:06:41 +02:00
Lukas Zanner
88e2cb4ae5 Fix uint64 vector unit tests
Firebird and SQLite store UINT64_MAX incorrectly, leading to an incorrect
value ordering when retrieving sorted table contents.
2023-08-13 17:25:32 +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
367c0c0341 Revert unnecessary changes in unit tests 2023-08-13 17:25:30 +02:00
Lukas Zanner
3d1617085c Replace stdint.h with cstdint 2023-08-13 17:25:29 +02:00
Lukas Zanner
44a4365c6e Update unit tests of SQLite3 backend for complete integer type support 2023-08-13 17:25:26 +02: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
Cosmin Cremarenco
9507d084cd Improve get_last_insert_id() for SQLite
Return the ID used for the given table instead of the last ID inserted
in any database table, which could be very different.

This relies on using internal sqlite_sequence table that is used by
AUTOINCREMENT.

Co-authored-by: Vadim Zeitlin <vz-soci@zeitlins.org>

Closes #971.
2022-06-20 19:12:57 +02:00
Cosmin Cremarenco
ae3ff29216 Add support for enforcing foreign keys in SQLite backend
Allow enabling foreign key checking, which is disabled by default in the
current SQLite versions, for the applications that need it using the
appropriate SQLite pragma if the corresponding connection string
parameter is specified.

Closes #968.
2022-05-19 23:51:24 +02:00
Cosmin Cremarenco
d46606432f Add support for XML to SQLite3 backend
SQLite doesn't have any specific XML support, but it can still be stored
in normal TEXT columns, which is better than not supporting it at all.

Closes #966.
2022-05-13 00:15:19 +02:00
Vadim Zeitlin
628ae300d9 Fix unqualified soci::session which broke macOS build
Bare "session" conflicts with a system header on that platform.
2021-04-02 16:16:45 +02:00