Kaydet (Commit) 9ccc1f59 authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

tdf#70425 Firebird: accept integers in setDouble

Change-Id: I471197a9c60ca28b93be0974956e5e1d90f843ca
Reviewed-on: https://gerrit.libreoffice.org/46125Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 521d92b3
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment