mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-06 00:03:16 -05:00
Return a proper QgsProviderConnectionException from python table()
Fixes #39151
This commit is contained in:
parent
096aa95ac7
commit
b0189b4149
@ -487,7 +487,7 @@ Raises a QgsProviderConnectionException if any errors are encountered.
|
||||
%End
|
||||
|
||||
|
||||
virtual QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table ) const;
|
||||
virtual QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table ) const throw( QgsProviderConnectionException );
|
||||
%Docstring
|
||||
Returns information on a ``table`` in the given ``schema``.
|
||||
Raises a QgsProviderConnectionException if any errors are encountered or if the table does not exist.
|
||||
|
||||
@ -526,7 +526,7 @@ class CORE_EXPORT QgsAbstractDatabaseProviderConnection : public QgsAbstractProv
|
||||
* \note Not available in Python bindings
|
||||
* \since QGIS 3.12
|
||||
*/
|
||||
virtual QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table ) const;
|
||||
virtual QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table ) const SIP_THROW( QgsProviderConnectionException );
|
||||
|
||||
/**
|
||||
* Returns information on the tables in the given schema.
|
||||
|
||||
@ -354,6 +354,14 @@ IMPORT FOREIGN SCHEMA qgis_test LIMIT TO ( "someData" )
|
||||
'out_db',
|
||||
'spatial_index'}))
|
||||
|
||||
def test_exceptions(self):
|
||||
"""Test that exception are converted to Python QgsProviderConnectionException"""
|
||||
|
||||
md = QgsProviderRegistry.instance().providerMetadata('postgres')
|
||||
conn = md.createConnection(self.uri, {})
|
||||
with self.assertRaises(QgsProviderConnectionException):
|
||||
conn.table('my_not_existent_schema', 'my_not_existent_table')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user