Skip to content

Commit

Permalink
Merge pull request #44051 from elpaso/connections-api-results-widget
Browse files Browse the repository at this point in the history
Connections api results widget
  • Loading branch information
elpaso committed Jul 10, 2021
2 parents 2071cd8 + a94e089 commit 91370a9
Show file tree
Hide file tree
Showing 50 changed files with 6,731 additions and 195 deletions.
21 changes: 21 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@
# --
Qgis.VectorExportResult.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SqlLayerDefinitionCapability.SubsetStringFilter.__doc__ = "SQL layer definition supports subset string filter"
Qgis.SqlLayerDefinitionCapability.GeometryColumn.__doc__ = "SQL layer definition supports geometry column"
Qgis.SqlLayerDefinitionCapability.PrimaryKeys.__doc__ = "SQL layer definition supports primary keys"
Qgis.SqlLayerDefinitionCapability.UnstableFeatureIds.__doc__ = "SQL layer definition supports disabling select at id"
Qgis.SqlLayerDefinitionCapability.__doc__ = 'SqlLayerDefinitionCapability enum lists the arguments supported by the provider when creating SQL query layers.\n\n.. versionadded:: 3.22\n\n' + '* ``SubsetStringFilter``: ' + Qgis.SqlLayerDefinitionCapability.SubsetStringFilter.__doc__ + '\n' + '* ``GeometryColumn``: ' + Qgis.SqlLayerDefinitionCapability.GeometryColumn.__doc__ + '\n' + '* ``PrimaryKeys``: ' + Qgis.SqlLayerDefinitionCapability.PrimaryKeys.__doc__ + '\n' + '* ``UnstableFeatureIds``: ' + Qgis.SqlLayerDefinitionCapability.UnstableFeatureIds.__doc__
# --
Qgis.SqlLayerDefinitionCapability.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SqlKeywordCategory.Keyword.__doc__ = "SQL keyword"
Qgis.SqlKeywordCategory.Constant.__doc__ = "SQL constant"
Qgis.SqlKeywordCategory.Function.__doc__ = "SQL generic function"
Qgis.SqlKeywordCategory.Geospatial.__doc__ = "SQL spatial function"
Qgis.SqlKeywordCategory.Operator.__doc__ = "SQL operator"
Qgis.SqlKeywordCategory.Math.__doc__ = "SQL math function"
Qgis.SqlKeywordCategory.Aggregate.__doc__ = "SQL aggregate function"
Qgis.SqlKeywordCategory.String.__doc__ = "SQL string function"
Qgis.SqlKeywordCategory.Identifier.__doc__ = "SQL identifier"
Qgis.SqlKeywordCategory.__doc__ = 'SqlKeywordCategory enum represents the categories of the SQL keywords used by the SQL query editor.\n\n.. note::\n\n The category has currently no usage, but it was planned for future uses.\n\n.. versionadded:: 3.22\n\n' + '* ``Keyword``: ' + Qgis.SqlKeywordCategory.Keyword.__doc__ + '\n' + '* ``Constant``: ' + Qgis.SqlKeywordCategory.Constant.__doc__ + '\n' + '* ``Function``: ' + Qgis.SqlKeywordCategory.Function.__doc__ + '\n' + '* ``Geospatial``: ' + Qgis.SqlKeywordCategory.Geospatial.__doc__ + '\n' + '* ``Operator``: ' + Qgis.SqlKeywordCategory.Operator.__doc__ + '\n' + '* ``Math``: ' + Qgis.SqlKeywordCategory.Math.__doc__ + '\n' + '* ``Aggregate``: ' + Qgis.SqlKeywordCategory.Aggregate.__doc__ + '\n' + '* ``String``: ' + Qgis.SqlKeywordCategory.String.__doc__ + '\n' + '* ``Identifier``: ' + Qgis.SqlKeywordCategory.Identifier.__doc__
# --
Qgis.SqlKeywordCategory.baseClass = Qgis
# monkey patching scoped based enum
Qgis.DriveType.Unknown.__doc__ = "Unknown type"
Qgis.DriveType.Invalid.__doc__ = "Invalid path"
Qgis.DriveType.Removable.__doc__ = "Removable drive"
Expand Down
2 changes: 2 additions & 0 deletions python/core/auto_generated/browser/qgslayeritem.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ Returns icon for point cloud layer

:return: the layer name
%End
virtual QgsAbstractDatabaseProviderConnection *databaseConnection() const;


};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,20 @@ Returns the next result row or an empty row if there are no rows left.
.. seealso:: :py:func:`rewind`
%End

qlonglong fetchedRowCount( ) const;
long long fetchedRowCount( ) const;
%Docstring
Returns the number of fetched rows.

.. seealso:: :py:func:`rowCount`
%End

long long rowCount( ) const;
%Docstring
Returns the number of rows returned by a SELECT query or Qgis.FeatureCountState.UnknownCount if unknown.

.. seealso:: :py:func:`fetchedRowCount`
%End


// Python iterator
QueryResult *__iter__();
Expand Down Expand Up @@ -118,9 +125,28 @@ Returns the number of fetched rows.



double queryExecutionTime( );
%Docstring
Returns the query execution time in milliseconds.
%End

void setQueryExecutionTime( double queryExecutionTime );
%Docstring
Sets the query execution time to ``queryExecutionTime`` milliseconds.
%End


};

struct SqlVectorLayerOptions
{
QString sql; //!< The SQL expression that defines the SQL (query) layer
QString filter; //!< Additional subset string (provider-side filter), not all data providers support this feature: check support with SqlLayerDefinitionCapability::Filters capability
QString layerName; //!< Optional name for the new layer
QStringList primaryKeyColumns; //!< List of primary key column names
QString geometryColumn; //!< Name of the geometry column
bool disableSelectAtId;
};

struct TableProperty
{
Expand Down Expand Up @@ -294,6 +320,11 @@ This information is calculated from the geometry columns types.

};

struct SpatialIndexOptions
{
QString geometryColumnName;
};

enum Capability
{
CreateVectorTable,
Expand Down Expand Up @@ -362,6 +393,13 @@ Returns connection geometry column capabilities (Z, M, SinglePart, Curves).
.. versionadded:: 3.16
%End

virtual Qgis::SqlLayerDefinitionCapabilities sqlLayerDefinitionCapabilities();
%Docstring
Returns SQL layer definition capabilities (Filters, GeometryColumn, PrimaryKeys).

.. versionadded:: 3.22
%End


virtual QString tableUri( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
%Docstring
Expand Down Expand Up @@ -434,7 +472,7 @@ Renames a raster table with given ``schema`` (schema is ignored if not supported
%Docstring
Creates a new schema with the specified ``name``.

:raises QgsProviderConnectionException:
:raises QgsProviderConnectionException: if any errors are encountered.
%End

virtual void dropSchema( const QString &name, bool force = false ) const throw( QgsProviderConnectionException );
Expand Down Expand Up @@ -486,7 +524,6 @@ Adds a field.
.. versionadded:: 3.16
%End


virtual void renameSchema( const QString &name, const QString &newName ) const throw( QgsProviderConnectionException );
%Docstring
Renames a schema with the specified ``name``.
Expand All @@ -496,7 +533,7 @@ Raises a :py:class:`QgsProviderConnectionException` if any errors are encountere

it is responsibility of the caller to handle open layers and registry entries.

:raises QgsProviderConnectionException:
:raises QgsProviderConnectionException: if any errors are encountered.
%End

virtual QList<QList<QVariant>> executeSql( const QString &sql, QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException );
Expand All @@ -506,6 +543,15 @@ Executes raw ``sql`` and returns the (possibly empty) list of results in a multi
.. seealso:: :py:func:`execSql`

:raises QgsProviderConnectionException: if any errors are encountered.
%End

virtual QgsVectorLayer *createSqlVectorLayer( const SqlVectorLayerOptions &options ) const throw( QgsProviderConnectionException ) /Factory/;
%Docstring
Creates and returns a (possibly invalid) vector layer based on the ``sql`` statement and optional ``options``.

:raises QgsProviderConnectionException: if any errors are encountered or if SQL layer creation is not supported.

.. versionadded:: 3.22
%End

virtual QueryResult execSql( const QString &sql, QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException );
Expand All @@ -526,11 +572,6 @@ Vacuum the database table with given ``schema`` and ``name`` (schema is ignored
:raises QgsProviderConnectionException: if any errors are encountered.
%End

struct SpatialIndexOptions
{
QString geometryColumnName;
};

virtual void createSpatialIndex( const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options = QgsAbstractDatabaseProviderConnection::SpatialIndexOptions() ) const throw( QgsProviderConnectionException );
%Docstring
Creates a spatial index for the database table with given ``schema`` and ``name`` (schema is ignored if not supported by the backend).
Expand Down Expand Up @@ -601,8 +642,10 @@ Returns the fields of a ``table`` and ``schema``.

.. note::

The default implementation creates a temporary vector layer, providers may
choose to override this method for a greater efficiency.
the default implementation creates a temporary vector layer, providers may
choose to override this method for a greater efficiency of to overcome provider's
behavior when the layer does not expose all fields (GPKG for example hides geometry
and primary key column).

:raises QgsProviderConnectionException: if any errors are encountered.

Expand All @@ -613,7 +656,7 @@ Returns the fields of a ``table`` and ``schema``.
%Docstring
Returns a list of native types supported by the connection.

:raises QgsProviderConnectionException:
:raises QgsProviderConnectionException: if any errors are encountered.

.. versionadded:: 3.16
%End
Expand All @@ -623,6 +666,17 @@ Returns a list of native types supported by the connection.
Returns the provider key.

.. versionadded:: 3.16
%End

virtual QMap<Qgis::SqlKeywordCategory, QStringList> sqlDictionary();
%Docstring
Returns a dictionary of SQL keywords supported by the provider.
The default implementation returns an list of common reserved words under the
"Keyword" and "Constant" categories.

Subclasses should add provider- and/or connection- specific words.

.. versionadded:: 3.22
%End

protected:
Expand Down
25 changes: 25 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ The development version
UserCanceled,
};

enum class SqlLayerDefinitionCapability
{
SubsetStringFilter,
GeometryColumn,
PrimaryKeys,
UnstableFeatureIds
};
typedef QFlags<Qgis::SqlLayerDefinitionCapability> SqlLayerDefinitionCapabilities;


enum class SqlKeywordCategory
{
Keyword,
Constant,
Function,
Geospatial,
Operator,
Math,
Aggregate,
String,
Identifier
};

enum class DriveType
{
Unknown,
Expand Down Expand Up @@ -362,6 +385,8 @@ QFlags<Qgis::BrowserItemCapability> operator|(Qgis::BrowserItemCapability f1, QF

QFlags<Qgis::SublayerQueryFlag> operator|(Qgis::SublayerQueryFlag f1, QFlags<Qgis::SublayerQueryFlag> f2);

QFlags<Qgis::SqlLayerDefinitionCapability> operator|(Qgis::SqlLayerDefinitionCapability f1, QFlags<Qgis::SqlLayerDefinitionCapability> f2);




Expand Down
42 changes: 41 additions & 1 deletion python/core/auto_generated/qgsqueryresultmodel.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,58 @@ Constructs a QgsQueryResultModel from a ``queryResult`` with optional ``parent``
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;


virtual void fetchMore( const QModelIndex &parent );

virtual bool canFetchMore( const QModelIndex &parent ) const;


QStringList columns() const;
%Docstring
Returns the column names
%End

QgsAbstractDatabaseProviderConnection::QueryResult queryResult() const;
%Docstring
Returns the query result

.. versionadded:: 3.22
%End

public slots:

void rowsReady( const QList<QList<QVariant> > &rows );
%Docstring
Triggered when ``newRows`` have been fetched and can be added to the model
Triggered when ``newRows`` have been fetched and can be added to the model.
%End

void cancel();
%Docstring
Cancels the row fetching.
%End


signals:

void fetchingComplete();
%Docstring
Emitted when rows have been fetched (all of them or a batch if `maxRows` was passed to :py:func:`~QgsQueryResultModel.fetchMoreRows` )
or when the fetching has been stopped (canceled).

.. seealso:: :py:func:`fetchMoreRows`
%End

void fetchMoreRows( qlonglong maxRows );
%Docstring
Emitted when more rows are requested.

:param maxRows: the number of rows that will be fetched.
%End

void fetchingStarted();
%Docstring
Emitted when fetching of rows has started
%End

};

/************************************************************************
Expand Down
39 changes: 39 additions & 0 deletions python/gui/auto_generated/codeeditors/qgscodeeditorsql.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,50 @@ code autocompletion.
Constructor for QgsCodeEditorSQL
%End


virtual ~QgsCodeEditorSQL();

void setFields( const QgsFields &fields );
%Docstring
Set field names to be added to the lexer API.

.. versionadded:: 3.14
%End

void setFieldNames( const QStringList &fieldNames );
%Docstring
Set field names to ``fieldNames`` to be added to the lexer API.

.. versionadded:: 3.18
%End

QStringList fieldNames() const;
%Docstring
Returns field names from the lexer API.

.. versionadded:: 3.22
%End

void setExtraKeywords( const QStringList &extraKeywords );
%Docstring
Set extra keywords to ``extraKeywords``.

Extra keywords are usually added
from provider connections and represent function and other provider specific
keywords.

.. versionadded:: 3.22
%End

QStringList extraKeywords() const;
%Docstring
Returns the extra keywords.

Extra keywords are usually added
from provider connections and represent function and other provider specific
keywords.

.. versionadded:: 3.22
%End

protected:
Expand Down
Loading

0 comments on commit 91370a9

Please sign in to comment.