diff options
author | Tamas Bunth <tamas.bunth@collabora.co.uk> | 2019-01-12 11:28:07 +0100 |
---|---|---|
committer | Tamás Bunth <btomi96@gmail.com> | 2019-01-12 12:47:24 +0100 |
commit | ead0a04e413018f94a307a1b621e53a5f4d25a70 (patch) | |
tree | 6656040dea177b9d7f09dd79de52eea08a869ebd /connectivity | |
parent | c76d9e23327fe02757cc0f2524db11ffd9fe1551 (diff) |
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@gmail.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 29 |
1 files changed, 26 insertions, 3 deletions
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 ? |