fixup handling of unsigned values
that overflow their signed counterpart type
Change-Id: I7d446a5fdddb9d5ef313c1bd022fd959b11dec28
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index bf78289..5a18711 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -204,8 +204,15 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
(*this) = getString();
break;
case DataType::BIGINT:
(*this) = getLong();
{
sal_Int64 nVal(getLong());
sal_uInt64 nuVal(getULong());
if (nVal == 0 && nuVal != 0)
(*this) = nuVal;
else
(*this) = nVal;
break;
}
case DataType::FLOAT:
(*this) = getFloat();
@@ -221,8 +228,15 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
(*this) = getInt16();
break;
case DataType::INTEGER:
(*this) = getInt32();
{
sal_Int32 nVal(getInt32());
sal_uInt32 nuVal(getUInt32());
if (nVal == 0 && nuVal != 0)
(*this) = nuVal;
else
(*this) = nVal;
break;
}
case DataType::BIT:
case DataType::BOOLEAN:
(*this) = getBool();
@@ -1498,7 +1512,7 @@ sal_uInt32 ORowSetValue::getUInt32() const
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
nRet = OUString(m_aValue.m_pString).toInt32();
nRet = OUString(m_aValue.m_pString).toUInt32();
break;
case DataType::FLOAT:
nRet = sal_uInt32(m_aValue.m_nFloat);
@@ -1645,7 +1659,7 @@ sal_uInt64 ORowSetValue::getULong() const
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
nRet = static_cast<sal_uInt64>(OUString(m_aValue.m_pString).toInt64());
nRet = static_cast<sal_uInt64>(OUString(m_aValue.m_pString).toUInt64());
break;
case DataType::FLOAT:
nRet = sal_uInt64(m_aValue.m_nFloat);
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 8d24548..39b7e91 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -1595,6 +1595,14 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
switch (_rValue.getValueTypeClass())
{
case TypeClass_UNSIGNED_HYPER:
{
sal_uInt64 nValue = 0;
OSL_VERIFY( _rValue >>= nValue );
_rxParameters->setString(_nColumnIndex, OUString::number(nValue));
}
break;
case TypeClass_UNSIGNED_LONG:
case TypeClass_HYPER:
{
sal_Int64 nValue = 0;
@@ -1627,7 +1635,6 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
_rxParameters->setByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
break;
case TypeClass_UNSIGNED_SHORT:
case TypeClass_SHORT:
_rxParameters->setShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
break;
@@ -1636,10 +1643,14 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
_rxParameters->setString(_nColumnIndex, OUString((sal_Unicode *)_rValue.getValue(),1));
break;
case TypeClass_UNSIGNED_LONG:
case TypeClass_UNSIGNED_SHORT:
case TypeClass_LONG:
_rxParameters->setInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
{
sal_Int32 nValue = 0;
OSL_VERIFY( _rValue >>= nValue );
_rxParameters->setInt(_nColumnIndex, nValue);
break;
}
case TypeClass_FLOAT:
_rxParameters->setFloat(_nColumnIndex, *(float*)_rValue.getValue());