diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2023-05-25 23:51:04 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-05-28 21:00:38 +0200 |
commit | db4a7dd4021723a7415099a9942f3d0b67ca75de (patch) | |
tree | 86104999bc142ded044d2534410e183bbae35d9a /dbaccess | |
parent | 44ef36194420af15ea1eca1e4258897e44e768b0 (diff) |
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 <serval2412@yahoo.fr>
(cherry picked from commit a16ff0aa4123ce1682a971d66fff60f4ba4606f7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152224
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/dlg/directsql.cxx | 17 |
1 files changed, 15 insertions, 2 deletions
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++; } } |