diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-12-27 16:58:05 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-12-27 18:22:20 +0100 |
commit | 8cf970d4b3dca4f2f93fcebb8910aaeeb7ccf5fe (patch) | |
tree | 7c037d2297fffaa6fc402f858c0cdd5cd70c1736 /connectivity | |
parent | 03c7cd9bbe3d46bb13a5cf1ad72ba0eaf702747e (diff) |
tdf#130595: Parameter query with :parameter IS NULL doesn't work
Problematic SQL here:
SELECT * FROM "Table1" WHERE "Name" = :name OR :name IS NULL
Firebird considers there are 2 parameters.
When providing an empty string, no pb, OPreparedStatement::setNull is called which is ok for both parameters
When providing a non empty string, we go to OPreparedStatement::setString. For first param no pb
but for second param, sql type is SQL_NULL so it must be taken into account
See https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull
for full details
Change-Id: I80dff259d85957e8547c098e4c48b642cce26804
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127593
Reviewed-by: Lionel Mamane <lionel@mamane.lu>
Tested-by: Jenkins
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 8d08a207a67c..04e65b9c5e95 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -262,6 +262,12 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, setBoolean(nParameterIndex, boolValue); break; } + case SQL_NULL: + { + // See https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull + pVar->sqldata = nullptr; + break; + } default: ::dbtools::throwSQLException( "Incorrect type for setString", |