diff options
author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2017-12-08 22:08:45 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-19 14:56:16 +0100 |
commit | 5a5fce18871dac91cf485030b915d674948cd95e (patch) | |
tree | 5f6f44fd9b65d7a7b21f40a28648ca7d5cdff077 /connectivity | |
parent | c0f0dbdb3620d69c230d2460949620f41a49bb0a (diff) |
tdf#70425 Firebird: accept integers in setDouble
Change-Id: I471197a9c60ca28b93be0974956e5e1d90f843ca
Reviewed-on: https://gerrit.libreoffice.org/46125
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Bunth <btomi96@gmail.com>
(cherry picked from commit 9ccc1f59446bc4a16b6d090a3b556e184eb5f159)
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index d21037da74e5..74969278b16f 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -405,7 +405,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) |