mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Add QgsAbstractDatabaseProviderConnection interface for retrieving relationships for a database
This commit is contained in:
parent
4981f1846f
commit
7236b50930
@ -9,6 +9,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsAbstractDatabaseProviderConnection : QgsAbstractProviderConnection
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
@ -354,6 +355,7 @@ This information is calculated from the geometry columns types.
|
||||
SetFieldDomain,
|
||||
AddFieldDomain,
|
||||
RenameField,
|
||||
RetrieveRelationships,
|
||||
};
|
||||
typedef QFlags<QgsAbstractDatabaseProviderConnection::Capability> Capabilities;
|
||||
|
||||
@ -779,6 +781,20 @@ Adds a new field ``domain`` to the database.
|
||||
:raises QgsProviderConnectionException: if any errors are encountered.
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
virtual QList< QgsWeakRelation > relationships( const QString &schema = QString(), const QString &tableName = QString() ) const throw( QgsProviderConnectionException );
|
||||
%Docstring
|
||||
Returns a list of relationships detected in the database.
|
||||
|
||||
This is supported on providers with the Capability.RetrieveRelationships capability only.
|
||||
|
||||
If a ``schema`` and/or ``tableName`` are specified, then only relationships where the specified table
|
||||
forms the left (or "parent" / "referenced") side of the relationship are retrieved.
|
||||
|
||||
:raises QgsProviderConnectionException: if any errors are encountered.
|
||||
|
||||
.. versionadded:: 3.28
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "qgsabstractdatabaseproviderconnection.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsexception.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsweakrelation.h"
|
||||
#include "qgsfeedback.h"
|
||||
|
||||
#include <QVariant>
|
||||
@ -1318,6 +1318,12 @@ void QgsAbstractDatabaseProviderConnection::addFieldDomain( const QgsFieldDomain
|
||||
checkCapability( Capability::AddFieldDomain );
|
||||
}
|
||||
|
||||
QList< QgsWeakRelation > QgsAbstractDatabaseProviderConnection::relationships( const QString &, const QString & ) const
|
||||
{
|
||||
checkCapability( Capability::RetrieveRelationships );
|
||||
return {};
|
||||
}
|
||||
|
||||
QString QgsAbstractDatabaseProviderConnection::TableProperty::defaultName() const
|
||||
{
|
||||
QString n = mTableName;
|
||||
|
||||
@ -20,13 +20,14 @@
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgis_core.h"
|
||||
#include "qgsfields.h"
|
||||
#include "qgsexception.h"
|
||||
#include "qgsvectordataprovider.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QgsFeedback;
|
||||
class QgsFieldDomain;
|
||||
class QgsWeakRelation;
|
||||
|
||||
|
||||
/**
|
||||
* \brief The QgsAbstractDatabaseProviderConnection class provides common functionality
|
||||
@ -504,6 +505,7 @@ class CORE_EXPORT QgsAbstractDatabaseProviderConnection : public QgsAbstractProv
|
||||
SetFieldDomain = 1 << 24, //!< Can set the domain for an existing field via setFieldDomainName() (since QGIS 3.26)
|
||||
AddFieldDomain = 1 << 25, //!< Can add new field domains to the database via addFieldDomain() (since QGIS 3.26)
|
||||
RenameField = 1 << 26, //!< Can rename existing fields via renameField() (since QGIS 3.28)
|
||||
RetrieveRelationships = 1 << 27, //!< Can retrieve relationships from the database (since QGIS 3.28)
|
||||
};
|
||||
Q_ENUM( Capability )
|
||||
Q_DECLARE_FLAGS( Capabilities, Capability )
|
||||
@ -888,6 +890,20 @@ class CORE_EXPORT QgsAbstractDatabaseProviderConnection : public QgsAbstractProv
|
||||
*/
|
||||
virtual void addFieldDomain( const QgsFieldDomain &domain, const QString &schema ) const SIP_THROW( QgsProviderConnectionException );
|
||||
|
||||
/**
|
||||
* Returns a list of relationships detected in the database.
|
||||
*
|
||||
* This is supported on providers with the Capability::RetrieveRelationships capability only.
|
||||
*
|
||||
* If a \a schema and/or \a tableName are specified, then only relationships where the specified table
|
||||
* forms the left (or "parent" / "referenced") side of the relationship are retrieved.
|
||||
*
|
||||
* \throws QgsProviderConnectionException if any errors are encountered.
|
||||
*
|
||||
* \since QGIS 3.28
|
||||
*/
|
||||
virtual QList< QgsWeakRelation > relationships( const QString &schema = QString(), const QString &tableName = QString() ) const SIP_THROW( QgsProviderConnectionException );
|
||||
|
||||
protected:
|
||||
|
||||
///@cond PRIVATE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user