diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2019-09-11 21:24:39 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2019-09-11 23:10:47 +0200 |
commit | 7289828e106081ddae0e053d306fef5ffd0dee3b (patch) | |
tree | 85d7073a8b016f651f3c7c83ab2c291aaa75a5d8 /connectivity | |
parent | 343df4dfb7242599afc3187b9c674037b7d5c6af (diff) |
tdf#120945: Relationship of tables isn't recognized by formwizard
The patch implements getExportedKeys which was lacking.
Console logs:
warn:connectivity.firebird:13144:18512:connectivity/source/drivers/firebird/DatabaseMetaData.cxx:1468: Not yet implemented
warn:legacy.osl:13144:18512:connectivity/source/drivers/firebird/DatabaseMetaData.cxx:1469: Not implemented yet!
The only difference with getImportedKeys is the fact that :
- in getImportedKeys, table name of Where condition is the foreign key
- in getExportedKeys, table name of Where condition should be the primary key
Instead of duplicating the whole code of getImportedKeys,
I created a local function which contains the main part.
Change-Id: Ia4497524fecf098257eec27e44e016a7cbe23480
Reviewed-on: https://gerrit.libreoffice.org/78822
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 22 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/DatabaseMetaData.hxx | 2 |
2 files changed, 14 insertions, 10 deletions
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx index 7de45f9021d8..76d32e70ba8d 100644 --- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx @@ -1460,20 +1460,19 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns( } uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( - const Any&, const OUString&, const OUString& ) + const Any&, const OUString&, const OUString& table ) { - // List the columns in a table which are foreign keys. This is actually - // never used anywhere in the LO codebase currently. Retrieval from firebird - // requires using a 5-table join. - SAL_WARN("connectivity.firebird", "Not yet implemented"); - OSL_FAIL("Not implemented yet!"); - // TODO implement - return new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eExportedKeys); + return ODatabaseMetaData::lcl_getKeys(false, table); } uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( const Any&, const OUString&, const OUString& table ) { + return ODatabaseMetaData::lcl_getKeys(true, table); +} + +uno::Reference< XResultSet > ODatabaseMetaData::lcl_getKeys(const bool& bIsImport, const OUString& table ) +{ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eImportedKeys); uno::Reference< XResultSet > xResultSet = pResultSet; @@ -1501,8 +1500,11 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( "ON PRIM.RDB$INDEX_NAME = PRIMARY_INDEX.RDB$INDEX_NAME " "INNER JOIN RDB$INDEX_SEGMENTS AS FOREIGN_INDEX " "ON FOREI.RDB$INDEX_NAME = FOREIGN_INDEX.RDB$INDEX_NAME " - "WHERE FOREI.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' " - "AND FOREI.RDB$RELATION_NAME = '"+ table +"'"; + "WHERE FOREI.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' "; + if (bIsImport) + sSQL = sSQL + "AND FOREI.RDB$RELATION_NAME = '"+ table +"'"; + else + sSQL = sSQL + "AND PRIM.RDB$RELATION_NAME = '"+ table +"'"; uno::Reference< XResultSet > rs = statement->executeQuery(sSQL); uno::Reference< XRow > xRow( rs, UNO_QUERY_THROW ); diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.hxx b/connectivity/source/drivers/firebird/DatabaseMetaData.hxx index dc55940fcfe5..95e744bcf7ef 100644 --- a/connectivity/source/drivers/firebird/DatabaseMetaData.hxx +++ b/connectivity/source/drivers/firebird/DatabaseMetaData.hxx @@ -38,6 +38,8 @@ namespace connectivity class ODatabaseMetaData : public ODatabaseMetaData_BASE { ::rtl::Reference<Connection> m_pConnection; + private: + css::uno::Reference< css::sdbc::XResultSet > lcl_getKeys( const bool& bIsImport, const OUString& table ); public: explicit ODatabaseMetaData(Connection* _pCon); |