From baf36e763f65cba54c8168d10ade4f38a5f62c64 Mon Sep 17 00:00:00 2001 From: Frank Schönheit Date: Fri, 16 Oct 2009 14:16:52 +0200 Subject: #i104329# introduce a dedicated PrimaryKeySupport property at DataSource.Settings, which determines whether a data source should (be assumed to) support primary keys. Valid values are TRUE (=> supports), FALSE (=> doesn't support) and VOID (=> use the old heuristics, i.e. consult XDatabaseMetaData.supportsCoreSQLGrammar) --- connectivity/inc/connectivity/dbmetadata.hxx | 11 +++++++++++ connectivity/source/commontools/dbmetadata.cxx | 21 +++++++++++++++++++++ connectivity/source/drivers/ado/ado.xcu | 5 +++++ connectivity/source/drivers/jdbc/jdbc.xcu | 5 +++++ connectivity/source/drivers/odbc/odbc.xcu | 5 +++++ 5 files changed, 47 insertions(+) (limited to 'connectivity') diff --git a/connectivity/inc/connectivity/dbmetadata.hxx b/connectivity/inc/connectivity/dbmetadata.hxx index 32662c5c157a..e1a38c71b5fe 100644 --- a/connectivity/inc/connectivity/dbmetadata.hxx +++ b/connectivity/inc/connectivity/dbmetadata.hxx @@ -121,6 +121,17 @@ namespace dbtools */ bool supportsSubqueriesInFrom() const; + /** checks whether the database supports primary keys + + Since there's no dedicated API to ask a database for this, a heuristics needs to be applied. + First, the PrimaryKeySupport settings of the data source is examined. If it is + or , then value is returned. If it is , then the database meta data are examined + for support of core SQL grammar, and the result is returned. The assumption is that a database/driver + which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience + shows this is true most of the time. + */ + bool supportsPrimaryKeys() const; + /** determines whether names in the database should be restricted to SQL-92 identifiers Effectively, this method checks the EnableSQL92Check property of the data source settings, diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 70220b1cd563..0c0e4b3e6bbc 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -256,6 +256,27 @@ namespace dbtools return supportsSubQueries; } + //-------------------------------------------------------------------- + bool DatabaseMetaData::supportsPrimaryKeys() const + { + lcl_checkConnected( *m_pImpl ); + + bool supportsPrimaryKeys = false; + try + { + Any setting; + if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) + || !( setting >>= supportsPrimaryKeys ) + ) + supportsPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return supportsPrimaryKeys; + } + //-------------------------------------------------------------------- const ::rtl::OUString& DatabaseMetaData::getIdentifierQuoteString() const { diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu index 236d38bd7ff7..8a106c70283f 100755 --- a/connectivity/source/drivers/ado/ado.xcu +++ b/connectivity/source/drivers/ado/ado.xcu @@ -115,6 +115,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index 73fe2e9adc55..953e669906be 100755 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -145,6 +145,11 @@ true + + + true + + diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu index cf306f10d57f..b3a9d7149650 100755 --- a/connectivity/source/drivers/odbc/odbc.xcu +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -150,6 +150,11 @@ true + + + true + + -- cgit