diff options
author | Frank Schönheit <frank.schoenheit@sun.com> | 2009-10-16 14:16:52 +0200 |
---|---|---|
committer | Frank Schönheit <frank.schoenheit@sun.com> | 2009-10-16 14:16:52 +0200 |
commit | baf36e763f65cba54c8168d10ade4f38a5f62c64 (patch) | |
tree | bcb34f1deda4f95a794a4afcd30fa48f20efed16 /connectivity | |
parent | f62c1a55c09050d54387312b4bd2e58bc8d869ad (diff) |
#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)
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/inc/connectivity/dbmetadata.hxx | 11 | ||||
-rw-r--r-- | connectivity/source/commontools/dbmetadata.cxx | 21 | ||||
-rwxr-xr-x | connectivity/source/drivers/ado/ado.xcu | 5 | ||||
-rwxr-xr-x | connectivity/source/drivers/jdbc/jdbc.xcu | 5 | ||||
-rwxr-xr-x | connectivity/source/drivers/odbc/odbc.xcu | 5 |
5 files changed, 47 insertions, 0 deletions
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 <code>PrimaryKeySupport<code> settings of the data source is examined. If it is <TRUE/> + or <FALSE/>, then value is returned. If it is <NULL/>, 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 @@ -257,6 +257,27 @@ namespace dbtools } //-------------------------------------------------------------------- + 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 { return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedIdentifierQuoteString, &XDatabaseMetaData::getIdentifierQuoteString ); 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 @@ <value>true</value> </prop> </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> 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 @@ <value>true</value> </prop> </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> 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 @@ <value>true</value> </prop> </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> |