Skip to content
Permalink
Browse files

Provider key getter and layer options

  • Loading branch information
elpaso committed Jul 7, 2020
1 parent 1d1b689 commit 8ded0f146e7544c695d24961b009f90620e9936f
@@ -475,9 +475,16 @@ Raises a QgsProviderConnectionException if any errors are encountered.
the default implementation creates a temporary vector layer, providers may
choose to override this method for a greater efficiency.

.. versionadded:: 3.18
.. versionadded:: 3.16

:raises :: py:class:`QgsProviderConnectionException`
%End

QString providerKey() const;
%Docstring
Returns the provider key

.. versionadded:: 3.16
%End

protected:
@@ -52,6 +52,11 @@ void QgsAbstractDatabaseProviderConnection::checkCapability( QgsAbstractDatabase
throw QgsProviderConnectionException( QObject::tr( "Operation '%1' is not supported for this connection" ).arg( capName ) );
}
}

QString QgsAbstractDatabaseProviderConnection::providerKey() const
{
return mProviderKey;
}
///@endcond

void QgsAbstractDatabaseProviderConnection::createVectorTable( const QString &schema,
@@ -215,7 +220,9 @@ QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType>

QgsFields QgsAbstractDatabaseProviderConnection::fields( const QString &schema, const QString &tableName ) const
{
QgsVectorLayer vl { tableUri( schema, tableName ), QStringLiteral( "temp_layer" ), mProviderKey };
QgsVectorLayer::LayerOptions options { true, true };
options.skipCrsValidation = true;
QgsVectorLayer vl { tableUri( schema, tableName ), QStringLiteral( "temp_layer" ), mProviderKey, options };
if ( vl.isValid() )
{
return vl.fields();
@@ -501,11 +501,17 @@ class CORE_EXPORT QgsAbstractDatabaseProviderConnection : public QgsAbstractProv
* Raises a QgsProviderConnectionException if any errors are encountered.
* \note the default implementation creates a temporary vector layer, providers may
* choose to override this method for a greater efficiency.
* \since QGIS 3.18
* \since QGIS 3.16
* \throws QgsProviderConnectionException
*/
virtual QgsFields fields( const QString &schema, const QString &table ) const SIP_THROW( QgsProviderConnectionException );

/**
* Returns the provider key
* \since QGIS 3.16
*/
QString providerKey() const;

protected:

///@cond PRIVATE

0 comments on commit 8ded0f1

Please sign in to comment.
You can’t perform that action at this time.