diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2023-05-25 23:51:04 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2023-05-26 09:09:53 +0200 |
commit | 16a8943f7dbf338377fe486cc75116b89742c7b0 (patch) | |
tree | ab8c111334f63f6eac366920340862c00cfc8727 /dbaccess | |
parent | 0360b9940833609b80b7cf0dd782f124212b01bb (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>
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++; } } |