Commit Graph

38 Commits

Author SHA1 Message Date
Vadim Zeitlin
ee72345f6e Merge branch 'wstring'
Add std::wstring support for ODBC backend.

See #1179.
2025-01-24 16:45:11 +01:00
Robert Adam
dc4815cac1 Implement session::get_last_query_with_context()
Allow retrieving the last query with the parameter values used for them.

See #678.

Closes #1027.

Closes #1164.
2025-01-24 16:24:59 +01:00
Benjamin Oldenburg
982434f170 Add std::wstring support for ODBC backend
Handle wide-strings similarly to how normal strings are already handled.

For now support for them is only available in the ODBC backend.

Also add conversion functions between UTF-{8,16,32} and wchar_t and the
tests for them. Note that some of these functions are not used yet, but
provide the complete set as they probably will be in the future.

Co-Authored-By: Vadim Zeitlin <vz-soci@zeitlins.org>
2024-11-17 16:49:25 +01:00
Robert Adam
552f321c05 Bind blobs to actual blob objects
This ensures that when binding blobs dynamically (e.g. in a row), they
are properly represented as a soci::blob object and not by a
std::string.
2024-01-13 17:09:30 +01:00
Vadim Zeitlin
a9b3508880 Make db_type to data_type conversion backend-dependent
It wasn't quite the same for all of them, notably MySQL and ODBC
disagreed about the mapping of db_uint32 and ODBC backend also mapped
db_uint64 to signed dt_long_long and not dt_unsigned_long_long as the
other backends, so make it possible to preserve its existing behaviour
by overriding to_data_type() in it.

There is still a minor incompatibility in MySQL backend: the type of
unsigned INT24 fields is now dt_long_long and not dt_integer as before,
but we can hopefully live with this.
2024-01-03 01:34:10 +01:00
Vadim Zeitlin
fdfcc12e8d Remove data_type argument from describe_column() backend function
This is unnecessary as it can be recovered from db_type: even if this is
not lossless, we don't really care about it if all we need is data_type,
so simplify the API and the implementation by only having one "type"
parameter instead of two.

No real changes.
2024-01-03 00:36:54 +01:00
Lukas Zanner
826fa7753a Expose new db_type for dynamic type mapping 2023-08-13 17:26:15 +02:00
Lukas Zanner
3d1617085c Replace stdint.h with cstdint 2023-08-13 17:25:29 +02:00
Lukas Zanner
764424040a Update core code for complete integer type support 2023-08-13 17:25:22 +02:00
Carsten Stiborg
924d990f8f Fix memory leak due to unbounded indicators vector growth
Clear the `statement_impl::indicators_` vector instead of just appending
more and more elements to it when using values-based API.

Closes #1058.

See #1061.
2023-07-17 16:23:44 +02:00
Vadim Zeitlin
721bb1aa9d Remove trailing whitespace from all files
No real changes.
2021-04-07 19:32:41 +02:00
Cavaler
b4f7ce8031 Allow using data of type dt_blob and dt_xml with rowset
There doesn't seem to be any good reason not to allow this.

Closes #786.
2020-02-10 18:44:01 +01:00
Vadim Zeitlin
d081e1248d Include the parameter number in the errors from post_fetch()
This makes errors such as e.g. "Null value fetched and no indicator
defined." much more useful, as the error message now says which
parameter exactly was null.

Closes #631.
2018-07-02 15:24:16 +02:00
Maciej Sobczak
138b29e431 Lazy initialization of the temporary LOB objects for Oracle. 2017-07-20 00:47:59 +02:00
Mateusz Łoskot
b78c8ef824 Merge pull request #358 from ArnaudD-FR/bind_clean_up
Split Statement::clean_up into bind_clean_up and clean_up
2015-07-24 11:26:18 +02:00
ArnaudD-FR
403b8de263 Fix bind_clean_up when using 'row' 2015-07-16 14:56:03 +02: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
ArnaudD-FR
a6b351449c Split Statement::clean_up into bind_clean_up and clean_up 2015-07-09 16:52:03 +02:00
Vadim Zeitlin
7e80c68341 Use parameter names from the query, if given, in error messages.
Improve the error messages by using the parameter names used in the query
itself, if any, when the query parameters were bound by position and not by
name.

This means that errors for a query like

            sql << "insert into soci_test(name, age) values (:name, :age)",
                   use(name), use(age));

will now contain "with :name=... :age=..." even though the parameter names
were not passed to use().
2015-04-16 17:01:38 +02:00
Mateusz Łoskot
e4376edaec Merge branch 'master' into develop-3.2.3
wip: Merging SOCI 3.2.3 changes (current master) into develop.

Conflicts:
	.gitignore
	.travis.yml
	AUTHORS
	CHANGES
	cmake/SociBackend.cmake
	cmake/modules/FindODBC.cmake
	docs/installation.html
	include/soci/boost-fusion.h
	include/soci/boost-tuple.h
	include/soci/odbc/soci-odbc.h
	include/soci/prepare-temp-type.h
	include/soci/ref-counted-prepare-info.h
	include/soci/soci-platform.h
	include/soci/statement.h
	include/soci/use.h
	include/soci/version.h
	src/CMakeLists.txt
	src/backends/postgresql/test/test-postgresql.cpp
	src/backends/sqlite3/blob.cpp
	src/backends/sqlite3/test/test-sqlite3.cpp
	src/core/CMakeLists.txt
	src/core/test/common-tests.h
	tests/mysql/test-mysql.cpp
	www/index.html
2015-04-09 23:43:22 +02:00
Adesmier
c799e4f6ed Append each member of tuple/fusion instead of adding tuple/fusion
* Warning: break compatibility with boost 1.35 released in 2008!
 * when calling use() or into() with tuple or fusion objects, it stores
   reference to each member of object instead of storing object reference
   thanks to boost::fusion::foreach.
 * Job is done by new use_type_vector and into_type_vector classes
2015-04-08 22:06:46 +02:00
Vadim Zeitlin
8bb66107a2 Provide context of the error in soci_error when possible.
Add soci_error::add_context() and use it in statement class to record the
information about the query which resulted in the exception and, if
applicable, this query parameters.

This results in much better end user experience as the error messages now
contain information allowing to diagnose which query exactly has failed
instead of just unhelpfully saying that an error occurred.
2015-04-01 15:24:12 +02:00
Vadim Zeitlin
e8e5978138 No real changes, just remove trailing whitespace.
Insignificant trailing whitespace was annoying as it resulted in extra noise
in the diffs, just get rid of it everywhere at once.
2015-04-01 14:52:39 +02:00
Vadim Zeitlin
417ef5cc4d Include all public headers using "soci/" prefix inside SOCI itself.
Harmonize the inclusion style of the headers from inside and outside the
library and always use the "soci/foo.h" form.
2014-03-25 15:53:32 +01:00
Ricardo Andrade
901f33bb15 Fixes false negatives in case of a partial placeholder matching. 2013-05-31 10:32:48 -03:00
Ricardo Andrade
92c2e8b21a Untabfy 2013-05-02 10:10:07 -03:00
Ricardo Andrade
087b24a087 soci::values placeholder search logic now looks for the following alphanumerical char to discard a match. 2013-05-02 09:32:15 -03:00
Ricardo Andrade
5d7df8ff91 Fixes the use of PostgreSQL-style casts with ORM (soci::values) 2013-05-02 09:31:25 -03:00
Mateusz Loskot
1e693d366d Untabify 2013-03-03 15:06:13 +00:00
Mateusz Loskot
d279c11e9b Fix memory leak of statement backend (issue #67)
The leak has been confirmed usign memory debugger. Applied fix suggested
by Evgeny Barabanov to perform allocated statement clean up if exception
is thrown from prepare() method.
2013-02-16 22:19:35 +00:00
Mateusz Loskot
5f0dd71377 Fix for #44 - Placeholder at the last position of statement causing crash
Patch received from Daniel Beaudoin (Optel Vision) on 23/07/2012)
2013-02-03 15:19:48 +00:00
Vadim Zeitlin
4f8bc05242 Remove dt_unsigned_long and x_unsigned_long type constants.
There is no need for a separate type for "unsigned long" as we don't have
special types neither for "unsigned int" nor for "long" and this type was not
handled correctly in the ODBC backend that mapped "unsigned int" to
SQL_BIGINT, even though the former is almost always 32 bits and the latter is
always 64 bits.

Simply remove these types to avoid the problem and simplify the code.

Signed-off-by: Vadim Zeitlin <vz-soci@zeitlins.org>
2012-07-10 22:36:04 +02:00
Mateusz Loskot
1070898f95 Use C++ cast operators. 2012-02-20 23:41:35 +00:00
Alex Ott
1f0c57417e correctly handle negative values
sometimes, get_number_of_rows can return negative value, and this could lead to crash when
trying to resize vector

Signed-off-by: Mateusz Loskot <mateusz@loskot.net>
2012-02-20 23:39:04 +00:00
Mateusz Loskot
d918c3ba78 bind_into now supports recently added dt_unsigned_long_long. Const correctness. Tidy up. 2010-12-20 02:02:09 +00:00
Maciej Sobczak
68a5f0931a Applied modified patch from Matthieu Kermagoret for get_affected_rows. 2010-12-06 11:49:36 +01:00
Maciej Sobczak
a638c3155c Corrected order of pre-use execution steps. 2010-01-21 23:57:11 +01:00
Maciej Sobczak
89676ff71a Moved CVS src module to its own directory. 2009-04-30 11:50:31 +02:00