mysqlc/source/mysqlc_prepared_resultset.cxx |    3 +++
 mysqlc/source/mysqlc_preparedstatement.cxx  |   21 +++++++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)

New commits:
commit aa6859f09068fa0380d0a23db4823f6ca1923037
Author:     Tamas Bunth <tamas.bu...@collabora.co.uk>
AuthorDate: Wed Aug 8 17:08:22 2018 +0200
Commit:     Tamás Bunth <btom...@gmail.com>
CommitDate: Sun Aug 12 23:16:59 2018 +0200

    mysqlc: Fix float, double and numeric types
    
    Change-Id: I9d0b989735e736c9c35d8acf4ea1b072eddf7437
    Reviewed-on: https://gerrit.libreoffice.org/58744
    Tested-by: Jenkins
    Reviewed-by: Tamás Bunth <btom...@gmail.com>

diff --git a/mysqlc/source/mysqlc_prepared_resultset.cxx 
b/mysqlc/source/mysqlc_prepared_resultset.cxx
index 3bc6b9424752..6ef50bea7116 100644
--- a/mysqlc/source/mysqlc_prepared_resultset.cxx
+++ b/mysqlc/source/mysqlc_prepared_resultset.cxx
@@ -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);
 }
 
diff --git a/mysqlc/source/mysqlc_preparedstatement.cxx 
b/mysqlc/source/mysqlc_preparedstatement.cxx
index 88b899a55814..9c6da76913e6 100644
--- a/mysqlc/source/mysqlc_preparedstatement.cxx
+++ b/mysqlc/source/mysqlc_preparedstatement.cxx
@@ -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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to