dbaccess/source/ui/dlg/directsql.cxx |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

New commits:
commit a4238b12ff0d5f77b3240a5f22c20ae8c0e2f828
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Fri May 26 14:00:32 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri May 26 19:22:47 2023 +0200

    Related tdf#153317: extra check since we deal with signed integers
    
    Thank you Michael Stahl for having spotted this! :-)
    
    Change-Id: I4e643b562e6dc653a511109531837c228f0e0e0b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152305
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Tested-by: Jenkins
    (cherry picked from commit 42547b6472cad484bced8aa47ecadd6d21d587ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152312
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/dbaccess/source/ui/dlg/directsql.cxx 
b/dbaccess/source/ui/dlg/directsql.cxx
index a82f8d4c10f8..856a20319b03 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -325,7 +325,7 @@ namespace dbaui
                     // In this case, there's a good chance it's a "Bit" field
                     // remark: for unknown reason, getByte(i) gives "\000" 
even if the bit is at 1.
                     auto seq = xRow->getBytes(i);
-                    if ((seq.getLength() == 1) && (seq[0] <= 1))
+                    if ((seq.getLength() == 1) && (seq[0] >= 0) && (seq[0] <= 
1))
                     {
                         out.append(OUString::number(static_cast<int>(seq[0])) 
+ ",");
                     }
commit 6d0470ee00cbf9f9d293c92f92a759cdacbebef0
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Thu May 25 23:51:04 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri May 26 19:22:34 2023 +0200

    tdf#153317: direct SQL: try to detect Bit field in Mysql/MariaDB
    
    Change-Id: I462cb28c15a0cd1d3c93f2335bcac02ca09c78e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152289
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    (cherry picked from commit a16ff0aa4123ce1682a971d66fff60f4ba4606f7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152224
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/dbaccess/source/ui/dlg/directsql.cxx 
b/dbaccess/source/ui/dlg/directsql.cxx
index 9080e63dca3f..a82f8d4c10f8 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -318,8 +318,21 @@ namespace dbaui
                 int i = 1;
                 for (;;)
                 {
-                    // be dumb, treat everything as a string
-                    out.append(xRow->getString(i) + ",");
+                    // be dumb, treat everything as a string unless below
+                    // tdf#153317, at least "Bit" type in Mysql/MariaDB gives: 
"\000" or "\001"
+                    // so retrieve Sequence from getBytes, test if it has a 
length of 1 (so we avoid BLOB/CLOB or other complex types)
+                    // and test if the value of first byte is one of those.
+                    // In this case, there's a good chance it's a "Bit" field
+                    // remark: for unknown reason, getByte(i) gives "\000" 
even if the bit is at 1.
+                    auto seq = xRow->getBytes(i);
+                    if ((seq.getLength() == 1) && (seq[0] <= 1))
+                    {
+                        out.append(OUString::number(static_cast<int>(seq[0])) 
+ ",");
+                    }
+                    else
+                    {
+                        out.append(xRow->getString(i) + ",");
+                    }
                     i++;
                 }
             }

Reply via email to