From 2e26ef34bf1a2e5d1293e45cf3b1415d9514b056 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 10 Jul 2019 19:06:13 +0200 Subject: tdf#126268: first byte is not used for the sign symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code is just broken, negative numbers and positive numbers above 25 are incorrectly migrated if using decimal. E.g: -1 -> 24,6 26 -> -6527'6 thus, delete it and pass the 8 bytes as they are to lcl_double_dabble. Note: this only fixes the positive numbers, -1 still returns 24,6 Code introduced in 6039d2463b4cc503b963811b3b1471de3291ee09 Change-Id: Id0e249e47a91b274a247fb7e8b71353114149650 Reviewed-on: https://gerrit.libreoffice.org/75375 Tested-by: Jenkins Reviewed-by: Lionel Elie Mamane Reviewed-by: Xisco FaulĂ­ --- dbaccess/qa/unit/data/tdf126268.odb | Bin 0 -> 4877 bytes dbaccess/qa/unit/tdf126268.cxx | 85 ++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 dbaccess/qa/unit/data/tdf126268.odb create mode 100644 dbaccess/qa/unit/tdf126268.cxx (limited to 'dbaccess/qa') diff --git a/dbaccess/qa/unit/data/tdf126268.odb b/dbaccess/qa/unit/data/tdf126268.odb new file mode 100644 index 000000000000..ffd00c140791 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..967d5e671ff0 --- /dev/null +++ b/dbaccess/qa/unit/tdf126268.cxx @@ -0,0 +1,85 @@ +/* -*- 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +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" } }; + +void Tdf126268Test::testNumbers() +{ + // the migration requires the file to be writable + utl::TempFile const temp(createTempCopy("tdf126268.odb")); + uno::Reference const xDocument = getDocumentForUrl(temp.GetURL()); + + uno::Reference xConnection = getConnectionForDocument(xDocument); + + // select basically everything from the .odb + uno::Reference statement = xConnection->createStatement(); + const OUString sql{ "SELECT ID, Column1, Column2 FROM tableTest ORDER BY ID" }; + + uno::Reference xRes = statement->executeQuery(sql); + uno::Reference 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(xDocument, uno::UNO_QUERY)); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Tdf126268Test); + +CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit