Commit Graph

53 Commits

Author SHA1 Message Date
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
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
Sergei Nikulov
b510e1a63d moved to latest Catch UT Framework (#544)
* Moved to latest Catch UT Framework
* Added -Wextra to gcc and clang
* Fixed discovered issues
2017-07-07 21:31:41 +03: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
2a8e8965e7 Added PostgreSQL unit tests for DDL and metadata. 2016-06-27 22:17:52 +02:00
James E. King, III
60abeb88c7 add a unit test for the postgresql uuid data type 2015-10-08 15:53:23 -04:00
Miha Ravselj
7623f76fe1 More and better MSVC warnings fixes.
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.
2015-07-15 03:37:25 +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
Mateusz Loskot
1e89d43640 Fully qualify 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 14:12:12 +02:00
Mateusz Loskot
3494b2ba6b Wrap stream operator for boost::optional<int> with HAVE_BOOST 2015-05-19 10:23:43 +02:00