[Libreoffice-commits] core.git: connectivity/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Jan 12 11:47:44 UTC 2019
connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 29 ++++++++--
1 file changed, 26 insertions(+), 3 deletions(-)
New commits:
commit ead0a04e413018f94a307a1b621e53a5f4d25a70
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Sat Jan 12 11:28:07 2019 +0100
Commit: Tamás Bunth <btomi96 at gmail.com>
CommitDate: Sat Jan 12 12:47:24 2019 +0100
tdf#122437 mysqlc: consider "types" parameter in..
..method XDatabaseMetadata::getTables() so it will return only those types
which are needed. This solves the problem that no tables appear in
"Relations.." window.
Change-Id: Ia02537c78917583f574ad788098c65a9acd43078
Reviewed-on: https://gerrit.libreoffice.org/66212
Tested-by: Jenkins
Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
index 3faf928cfcdb..419d8e7acb9e 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
@@ -829,14 +829,37 @@ Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalo
Reference<XResultSet> SAL_CALL ODatabaseMetaData::getTables(const Any& /*catalog*/,
const OUString& schemaPattern,
const OUString& tableNamePattern,
- const Sequence<OUString>& /*types */)
+ const Sequence<OUString>& types)
{
- OUString query(
+ OUStringBuffer buffer{
"SELECT TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME,"
"IF(STRCMP(TABLE_TYPE,'BASE TABLE'), TABLE_TYPE, 'TABLE') AS TABLE_TYPE, TABLE_COMMENT AS "
"REMARKS "
"FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE '?' AND TABLE_NAME LIKE '?' "
- "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME");
+ };
+
+ if (types.getLength() == 1)
+ {
+ buffer.append("AND TABLE_TYPE LIKE '");
+ buffer.append(types[0]);
+ buffer.append("'");
+ }
+ else if (types.getLength() > 1)
+ {
+ buffer.append("AND (TABLE_TYPE LIKE '");
+ buffer.append(types[0]);
+ buffer.append("'");
+ for (sal_Int32 i = 1; i < types.getLength(); ++i)
+ {
+ buffer.append(" OR TABLE_TYPE LIKE '");
+ buffer.append(types[i]);
+ buffer.append("'");
+ }
+ buffer.append(")");
+ }
+
+ buffer.append(" ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME");
+ OUString query = buffer.makeStringAndClear();
// TODO use prepared stmt instead
// TODO escape schema, table name ?
More information about the Libreoffice-commits
mailing list