Fix compilation issues for Visual C++ 8.0 (VS2005)
* Add _WIN32_WINNT minimal required version to soci-platform.h to fix windows.h issue related to use of Add/RemoveVectoredExceptionHandler.
* Override SECTION macro since default macro parameter (3 required / 2 given or 2 required / 1 given) do not expand and lead to syntax error.
Adding a new line to work around the problem with Oracle didn't allow
this test to pass with SQL Server which strips the newline if it is
present.
So don't modify the input, but do strip the trailing newline from output
if it's present in it to accommodate Oracle, but to allow SQL Server to
work too.
The changes of be4f26feac (ODBC) and
51c4c1e1a3 (DB2) didn't handle null
strings correctly, the indicator value for them is -1 and can't be used
as length.
Fix this now by adding a test for this particular case.
Closes#581.
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.
Mention that the exact result of this method can't be relied upon for
the partially successful statements when using ODBC: some drivers
(including the widely used MS SQL native client) simply don't return
this information at all, while others (MySQL) just return wrong number
of rows.
Also remove the apparently obsolete note about this method not supported
in the Oracle backend as it does seem to implement it.
These functions are helpful to allow writing queries not using any
tables portably, i.e. they basically abstract the difference between
"select ... from dual" in Oracle and just "select ..." in almost all the
other backends.
Defining cxx_details::auto_ptr<> as either std::auto_ptr<> or
std::unique_ptr<> once instead of checking for SOCI_HAVE_CXX_C11 simplifies
the code and also allows to use unique_ptr<> for MSVS 2010+ which has it even
when SOCI_HAVE_CXX_C11 is not defined.
Also use cxx_details::auto_ptr<> instead of std::auto_ptr<> in the tests to
fix the build in C++11 mode with clang 3.8 due to -Wdeprecated-declarations
warnings given by it for std::auto_ptr<> (and -Werror used by CMake and which
apparently can't be overridden from command line...).
Use the new CHECK_EQUAL_PADDED() macro instead of just CHECK() for the CHAR(N)
fields as they can be padded, and even padded incorrectly, by some backends.
Add a new test verifying that, up to padding, CHAR(N) fields do behave
correctly.
Closes#356.
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.
"inline namespace" doesn't compile in C++98 mode, so the old code broke
compilation with g++ 4.7 or later or clang when not using C++11.
It also seems to be completely useless as outputting "Currently not supported"
just can't be a good idea, so it is not clear why was it added in the first
place (see PR #336).
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
Originally, it was an example sent to user.
No need to actually run the test, especially if purposely handled compiler
detection is needed. Keep it as an example to users who browse the tests.
Silently truncating the data to fit into a column is a bad idea, just don't do
this.
Also add a unit test verifying that an exception is indeed thrown if the value
being inserted doesn't fit in the column, except for SQLite where anything
fits and MySQL where it doesn't but just gets silently truncated by the
database by default.
Finally add a helper on_after_ddl() method to the test context class to allow
creating tables in the common test code instead of having to always do it in
RDBMS-specific way, even when the DDL uses completely standard SQL and the
only difference is that Firebird needs a commit after executing it.
Closes#51.
This makes it possible to reuse various MySQL-specific workarounds for both
tests without duplicating the not always trivial code.
As a side effect, fixes ODBC MySQL test which didn't pass any more since the
addition of exact double equality checks, making it use the same has_fp_bug()
as the MySQL test skips the failing test for it too now.
Put the common test cases in their own namespace to avoid a clash between the
tests defined in soci::tests (which is brought into scope via using
directive by all the backend-specific files) and the tests defined in the
backend test sources if they happen to start at the same line.
This is just a workaround and a proper solution would, of course, be to move
the tests out of the header at all but this will have to wait.
This makes the test slightly shorter (the line creating the table doesn't need
to be repeated many times) and, more importantly, allows us to specify the
descriptions which can be useful in case of test failures.
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.
This will only become useful after the upcoming commits which will extend
what() to return more information about the exception, but commit this
separately as there are only trivial changes in this commit: just use
std::string returned by get_error_message() instead of char* returned by
what() in the tests.
"assert" in the name of the directory doesn't make any sense any more as we
don't use asserts in the test code now that we use CATCH.
Also extend the tests description in the README.md.