[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - connectivity/qa

Tamas Bunth (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 3 12:23:04 UTC 2019


 connectivity/qa/connectivity/mysql/mysql.cxx |   45 +++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

New commits:
commit fbaa95177333c8ca5cb4c0f07c7bf9f53a01af26
Author:     Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Wed Jul 31 14:20:21 2019 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Sat Aug 3 14:22:13 2019 +0200

    mysqlc: Add test for textual blob types
    
    Test setting and querying the following data types:
    TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT
    
    Test them using prepared statements.
    
    Change-Id: I43387034ad8c32c3731cde70a22cc8b3dd652b78
    Reviewed-on: https://gerrit.libreoffice.org/76747
    Tested-by: Jenkins
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
    (cherry picked from commit cbbda5b9267f9f7c7028ebc3f0867ddc6715543a)
    Reviewed-on: https://gerrit.libreoffice.org/76874
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx
index 24af725b0110..47d1d7929e44 100644
--- a/connectivity/qa/connectivity/mysql/mysql.cxx
+++ b/connectivity/qa/connectivity/mysql/mysql.cxx
@@ -55,6 +55,7 @@ public:
     void testTimestampField();
     void testNumericConversionPrepared();
     void testPreparedStmtIsAfterLast();
+    void testGetStringFromBloColumnb();
 
     CPPUNIT_TEST_SUITE(MysqlTestDriver);
     CPPUNIT_TEST(testDBConnection);
@@ -65,6 +66,7 @@ public:
     CPPUNIT_TEST(testTimestampField);
     CPPUNIT_TEST(testNumericConversionPrepared);
     CPPUNIT_TEST(testPreparedStmtIsAfterLast);
+    CPPUNIT_TEST(testGetStringFromBloColumnb);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -444,6 +446,49 @@ void MysqlTestDriver::testPreparedStmtIsAfterLast()
     bool hasData = xResultSet->next();
     CPPUNIT_ASSERT(!hasData); // now we are on "AfterLast"
     CPPUNIT_ASSERT(xResultSet->isAfterLast());
+    xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable");
+}
+
+void MysqlTestDriver::testGetStringFromBloColumnb()
+{
+    Reference<XConnection> xConnection = m_xDriver->connect(m_sUrl, m_infos);
+    if (!xConnection.is())
+        CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is());
+    uno::Reference<XStatement> xStatement = xConnection->createStatement();
+    CPPUNIT_ASSERT(xStatement.is());
+    xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable");
+
+    // create test table
+    xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY, tinytexty "
+                              "TINYTEXT, texty TEXT, mediumTexty MEDIUMTEXT, longtexty LONGTEXT)");
+    Reference<XPreparedStatement> xPrepared = xConnection->prepareStatement(
+        OUString{ "INSERT INTO myTestTable VALUES (?, ?, ?, ?, ?)" });
+    Reference<XParameters> xParams(xPrepared, UNO_QUERY);
+    constexpr int ROW_COUNT = 6;
+    for (int i = 0; i < ROW_COUNT; ++i)
+    {
+        xParams->setShort(1, i);
+        xParams->setString(2, OUString::number(i));
+        xParams->setString(3, OUString::number(i));
+        xParams->setString(4, OUString::number(i));
+        xParams->setString(5, OUString::number(i));
+        xPrepared->executeUpdate();
+    }
+
+    // query test table
+    xPrepared = xConnection->prepareStatement(
+        "SELECT tinytexty, texty, mediumtexty, longtexty from myTestTable where texty LIKE '3'");
+    Reference<XResultSet> xResultSet = xPrepared->executeQuery();
+    xResultSet->next();
+    Reference<XRow> xRow(xResultSet, UNO_QUERY);
+
+    // all the textual blob types should be able to be queried via getString().
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(1));
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(2));
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(3));
+    CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(4));
+
+    xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable");
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(MysqlTestDriver);


More information about the Libreoffice-commits mailing list