connectivity/source/drivers/firebird/PreparedStatement.cxx | 32 ++++++++++++- connectivity/source/drivers/firebird/PreparedStatement.hxx | 2 2 files changed, 31 insertions(+), 3 deletions(-)
New commits: commit 9ccc1f59446bc4a16b6d090a3b556e184eb5f159 Author: Tamas Bunth <tamas.bu...@collabora.co.uk> Date: Fri Dec 8 22:08:45 2017 +0100 tdf#70425 Firebird: accept integers in setDouble Change-Id: I471197a9c60ca28b93be0974956e5e1d90f843ca Reviewed-on: https://gerrit.libreoffice.org/46125 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Bunth <btom...@gmail.com> diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 400b6c147cf8..3dfb092d12e7 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -350,7 +350,7 @@ void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 nIndex, sal_Bool bValue) } template <typename T> -void OPreparedStatement::setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType) +void OPreparedStatement::setValue(sal_Int32 nIndex, const T& nValue, ISC_SHORT nType) { MutexGuard aGuard( m_aMutex ); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); @@ -399,7 +399,35 @@ void SAL_CALL OPreparedStatement::setFloat(sal_Int32 nIndex, float nValue) void SAL_CALL OPreparedStatement::setDouble(sal_Int32 nIndex, double nValue) { - setValue< double >(nIndex, nValue, SQL_DOUBLE); // TODO: SQL_D_FLOAT? + MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); + ensurePrepared(); + + XSQLVAR* pVar = m_pInSqlda->sqlvar + (nIndex - 1); + int dType = (pVar->sqltype & ~1); // drop flag bit for now + + // Caller might try to set an integer type here. It makes sense to convert + // it instead of throwing an error. + switch(dType) + { + case SQL_SHORT: + setValue< sal_Int16 >(nIndex, + static_cast<sal_Int16>(nValue), + dType); + break; + case SQL_LONG: + setValue< sal_Int32 >(nIndex, + static_cast<sal_Int32>(nValue), + dType); + break; + case SQL_INT64: + setValue< sal_Int64 >(nIndex, + static_cast<sal_Int64>(nValue), + dType); + break; + default: + setValue< double >(nIndex, nValue, SQL_DOUBLE); // TODO: SQL_D_FLOAT? + } } void SAL_CALL OPreparedStatement::setDate(sal_Int32 nIndex, const Date& rDate) diff --git a/connectivity/source/drivers/firebird/PreparedStatement.hxx b/connectivity/source/drivers/firebird/PreparedStatement.hxx index 986752cd66c1..81910ad1f3dd 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.hxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.hxx @@ -64,7 +64,7 @@ namespace connectivity * @throws css::sdbc::SQLException * @throws css::uno::RuntimeException */ - template <typename T> void setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType); + template <typename T> void setValue(sal_Int32 nIndex, const T& nValue, ISC_SHORT nType); void setParameterNull(sal_Int32 nParameterIndex, bool bSetNull = true); /// @throws css::sdbc::SQLException
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits