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

mysqlc: Fix float, double and numeric types

Change-Id: I9d0b989735e736c9c35d8acf4ea1b072eddf7437
Reviewed-on: https://gerrit.libreoffice.org/58744
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 3478d745
......@@ -239,6 +239,9 @@ double SAL_CALL OPreparedResultSet::getDouble(sal_Int32 column)
}
m_bWasNull = false;
if (m_aFields[column - 1].type == MYSQL_TYPE_FLOAT)
return *reinterpret_cast<float*>(m_aData[column - 1].buffer);
return *reinterpret_cast<double*>(m_aData[column - 1].buffer);
}
......
......@@ -439,23 +439,24 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo(sal_Int32 parameterIndex, co
case DataType::DECIMAL:
case DataType::NUMERIC:
{
double nValue(0);
double nValue(0.0);
rtl::OUString sValue;
if ( value >>= nValue )
{
setDouble( parameterIndex, nValue );
break;
}
else
else if ( value >>= sValue )
{
rtl::OUString sValue;
if( value >>= sValue )
{
m_binds[nIndex].buffer_type = MYSQL_TYPE_NEWDECIMAL;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, sValue.getStr(), MYSQL_TYPE_LONGLONG, sValue.getLength());
m_bindMetas[nIndex].is_null = 0;
}
rtl::OString sAscii = rtl::OUStringToOString(sValue, getOwnConnection()->getConnectionEncoding());
std::stringstream sStream{sAscii.getStr()};
sStream >> nValue;
m_binds[nIndex].buffer_type = MYSQL_TYPE_DOUBLE;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &nValue, MYSQL_TYPE_DOUBLE, sValue.getLength());
m_bindMetas[nIndex].is_null = 0;
break;
}
#if defined __GNUC__ && __GNUC__ >= 7
[[fallthrough]];
#else
......
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