[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - dbaccess/CppunitTest_dbaccess_tdf126268.mk dbaccess/Module_dbaccess.mk dbaccess/qa dbaccess/source

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 17 08:45:41 UTC 2019


 dbaccess/CppunitTest_dbaccess_tdf126268.mk       |  107 +++++++++++++++++++++++
 dbaccess/Module_dbaccess.mk                      |    1 
 dbaccess/qa/unit/data/tdf126268.odb              |binary
 dbaccess/qa/unit/tdf126268.cxx                   |   87 ++++++++++++++++++
 dbaccess/source/filter/hsqldb/rowinputbinary.cxx |    4 
 5 files changed, 197 insertions(+), 2 deletions(-)

New commits:
commit d8bb7ae9cf2b9ff241be7876fdc8b1a5a6252475
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Wed Jul 10 19:06:13 2019 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Jul 17 10:44:58 2019 +0200

    tdf#126268: Check for the sign value at the right place
    
    This commit contains 25277bcb727994072239c9c2549c271fdd62150e
    and 2e26ef34bf1a2e5d1293e45cf3b1415d9514b056 for backporting
    
    Code introduced in 6039d2463b4cc503b963811b3b1471de3291ee09
    
    Change-Id: Id0e249e47a91b274a247fb7e8b71353114149650
    Reviewed-on: https://gerrit.libreoffice.org/75375
    Tested-by: Jenkins
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/75420
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/dbaccess/CppunitTest_dbaccess_tdf126268.mk b/dbaccess/CppunitTest_dbaccess_tdf126268.mk
new file mode 100644
index 000000000000..379e2f27433b
--- /dev/null
+++ b/dbaccess/CppunitTest_dbaccess_tdf126268.mk
@@ -0,0 +1,107 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,dbaccess_tdf126268))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,dbaccess_tdf126268, \
+    dbaccess/qa/unit/tdf126268 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,dbaccess_tdf126268, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    dba \
+	dbahsql \
+    dbu \
+    sdbt \
+    drawinglayer \
+    editeng \
+    for \
+    forui \
+    i18nlangtag \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+    test \
+    subsequenttest \
+    tl \
+    tk \
+    ucbhelper \
+	unotest \
+    utl \
+    vbahelper \
+    vcl \
+    xo \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,dbaccess_tdf126268))
+$(eval $(call gb_CppunitTest_use_vcl,dbaccess_tdf126268))
+
+$(eval $(call gb_CppunitTest_set_include,dbaccess_tdf126268,\
+	-I$(SRCDIR)/dbaccess/source/filter/hsqldb \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,dbaccess_tdf126268,\
+    offapi \
+    oovbaapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_components,dbaccess_tdf126268,\
+    basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    connectivity/source/drivers/hsqldb/hsqldb \
+    connectivity/source/drivers/firebird/firebird_sdbc \
+    connectivity/source/manager/sdbc2 \
+    dbaccess/util/dba \
+    dbaccess/util/dbu \
+    dbaccess/util/sdbt \
+    dbaccess/source/filter/xml/dbaxml \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    scripting/source/basprov/basprov \
+    scripting/util/scriptframe \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/source/fsstor/fsstorage \
+    svl/util/svl \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    ucb/source/ucp/tdoc/ucptdoc1 \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+    uui/util/uui \
+    xmloff/util/xo \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,dbaccess_tdf126268))
+
+# vim: set noet sw=4 ts=4:
diff --git a/dbaccess/Module_dbaccess.mk b/dbaccess/Module_dbaccess.mk
index a45acd3af2f4..0a66d5fe7586 100644
--- a/dbaccess/Module_dbaccess.mk
+++ b/dbaccess/Module_dbaccess.mk
@@ -37,6 +37,7 @@ ifeq ($(ENABLE_FIREBIRD_SDBC),TRUE)
 $(eval $(call gb_Module_add_check_targets,dbaccess,\
     $(if $(ENABLE_JAVA),CppunitTest_dbaccess_hsqlbinary_import) \
     $(if $(ENABLE_JAVA),CppunitTest_dbaccess_tdf119625) \
+    $(if $(ENABLE_JAVA),CppunitTest_dbaccess_tdf126268) \
 ))
 
 # remove if we have a be file for this
diff --git a/dbaccess/qa/unit/data/tdf126268.odb b/dbaccess/qa/unit/data/tdf126268.odb
new file mode 100644
index 000000000000..434a4238ba3b
Binary files /dev/null and b/dbaccess/qa/unit/data/tdf126268.odb differ
diff --git a/dbaccess/qa/unit/tdf126268.cxx b/dbaccess/qa/unit/tdf126268.cxx
new file mode 100644
index 000000000000..ffbe6361a231
--- /dev/null
+++ b/dbaccess/qa/unit/tdf126268.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "dbtest_base.cxx"
+
+#include <hsqlimport.hxx>
+
+#include <osl/process.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <test/unoapi_test.hxx>
+#include <svtools/miscopt.hxx>
+
+using namespace dbahsql;
+
+class Tdf126268Test : public DBTestBase
+{
+public:
+    void testNumbers();
+
+    virtual void setUp() override;
+
+    CPPUNIT_TEST_SUITE(Tdf126268Test);
+
+    CPPUNIT_TEST(testNumbers);
+
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void Tdf126268Test::setUp()
+{
+    DBTestBase::setUp();
+    SvtMiscOptions aMiscOptions;
+    osl_setEnvironment(OUString{ "DBACCESS_HSQL_MIGRATION" }.pData, OUString{ "1" }.pData);
+}
+
+struct expect_t
+{
+    sal_Int16 id;
+    OUString number;
+};
+
+static const expect_t expect[] = {
+    { 1, "0.00" },   { 2, "25.00" },  { 3, "26.00" }, { 4, "30.4" },  { 5, "45.8" },
+    { 6, "-25.00" }, { 7, "-26.00" }, { 8, "-30.4" }, { 9, "-45.8" },
+};
+
+void Tdf126268Test::testNumbers()
+{
+    // the migration requires the file to be writable
+    utl::TempFile const temp(createTempCopy("tdf126268.odb"));
+    uno::Reference<XOfficeDatabaseDocument> const xDocument = getDocumentForUrl(temp.GetURL());
+
+    uno::Reference<XConnection> xConnection = getConnectionForDocument(xDocument);
+
+    // select basically everything from the .odb
+    uno::Reference<XStatement> statement = xConnection->createStatement();
+    const OUString sql{ "SELECT ID, Column1, Column2 FROM tableTest ORDER BY ID" };
+
+    uno::Reference<XResultSet> xRes = statement->executeQuery(sql);
+    uno::Reference<XRow> xRow(xRes, UNO_QUERY_THROW);
+
+    // check result
+    for (auto& e : expect)
+    {
+        CPPUNIT_ASSERT(xRes->next());
+        CPPUNIT_ASSERT_EQUAL(e.id, xRow->getShort(1));
+        CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(2)); //decimal
+        CPPUNIT_ASSERT_EQUAL(e.number, xRow->getString(3)); //numeric
+    }
+    CPPUNIT_ASSERT(!xRes->next());
+
+    closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Tdf126268Test);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index 24448f627971..13cb731d0877 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -89,10 +89,10 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
 OUString lcl_makeStringFromBigint(const std::vector<sal_uInt8>& bytes)
 {
     std::vector<sal_uInt8> aBytes{ bytes };
-
     OUStringBuffer sRet;
+
     // two's complement
-    if (aBytes[0] == 1)
+    if ((aBytes[0] & 0x80) != 0)
     {
         sRet.append("-");
         for (auto& byte : aBytes)


More information about the Libreoffice-commits mailing list