summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-10-14 17:59:10 +0200
committerCaolán McNamara <caolanm@redhat.com>2013-10-21 13:18:47 +0000
commit1129d2bfa825a73dc0a619fa3e45a277eaffcb86 (patch)
treec60e5c615a267444103a2651b5cb02ca89c8f1bc /connectivity
parent11726693c3d57e86e391f60370f1b42030ef69ea (diff)
fdo#68657 bool->string conversion to 1/0, not "true"/"false
This matches what OO.org / older versions of LibreOffice did, and which was inadvertently changed in 2bd856e6 Change-Id: I1d45ea975a096c599a996caafc41e4aa06d35fcd Reviewed-on: https://gerrit.libreoffice.org/6274 Reviewed-by: David Ostrovsky <David.Ostrovsky@gmx.de> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/qa/connectivity/commontools/FValue_test.cxx24
-rw-r--r--connectivity/source/commontools/FValue.cxx9
2 files changed, 32 insertions, 1 deletions
diff --git a/connectivity/qa/connectivity/commontools/FValue_test.cxx b/connectivity/qa/connectivity/commontools/FValue_test.cxx
index b460f646ded5..73b8af5f821f 100644
--- a/connectivity/qa/connectivity/commontools/FValue_test.cxx
+++ b/connectivity/qa/connectivity/commontools/FValue_test.cxx
@@ -46,6 +46,8 @@ public:
void test_float();
void test_double();
+ void test_getString();
+
CPPUNIT_TEST_SUITE(FValueTest);
CPPUNIT_TEST(test_Bool);
@@ -65,6 +67,7 @@ public:
CPPUNIT_TEST(test_float);
CPPUNIT_TEST(test_double);
+ CPPUNIT_TEST(test_getString);
CPPUNIT_TEST_SUITE_END();
};
@@ -283,6 +286,27 @@ void FValueTest::test_double()
CPPUNIT_ASSERT_MESSAGE("double conversion from Any didn't work", src_double == trg_double);
}
+void FValueTest::test_getString()
+{
+ bool src_bool_1 = true;
+ ORowSetValue v_1(src_bool_1);
+ OUString trg_bool_1 = v_1.getString();
+
+ std::cerr << "src_bool_1" << src_bool_1 << std::endl;
+ std::cerr << "trg_bool_1: " << trg_bool_1 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("bool to string conversion to ORowSetValue didn't work", trg_bool_1 == "1");
+
+ bool src_bool_0 = false;
+ ORowSetValue v_0(src_bool_0);
+ OUString trg_bool_0 = v_0.getString();
+
+ std::cerr << "src_bool_0" << src_bool_0 << std::endl;
+ std::cerr << "trg_bool_0: " << trg_bool_0 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("bool to string conversion to ORowSetValue didn't work", trg_bool_0 == "0");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest);
}}
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index 770b34ea43c9..0dd208ca1cc0 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -27,6 +27,8 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
+#include <boost/type_traits.hpp>
+#include <boost/static_assert.hpp>
using namespace ::dbtools;
using namespace ::com::sun::star::sdbc;
@@ -1007,7 +1009,12 @@ OUString ORowSetValue::getString( ) const
break;
case DataType::BIT:
case DataType::BOOLEAN:
- aRet = OUString::boolean(static_cast<bool>(*this));
+ // This would be the natural choice,
+ // but historically it was converted to "0" or "1".
+ // For backwards compatibility, continue doing that.
+ // aRet = OUString::boolean(static_cast<bool>(*this));
+ BOOST_STATIC_ASSERT((boost::is_same< sal_Bool, sal_uInt8 >::value));
+ aRet = OUString::number(static_cast<sal_Bool>(*this));
break;
case DataType::TINYINT:
case DataType::SMALLINT: