Skip to content

Commit

Permalink
Provider QSCI APIs for sqlite and PG
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jul 6, 2021
1 parent af9febc commit 27eb574
Show file tree
Hide file tree
Showing 16 changed files with 2,947 additions and 7 deletions.
Expand Up @@ -11,3 +11,4 @@
QgsAbstractDatabaseProviderConnection.SqlLayerDefinitionCapability.baseClass = QgsAbstractDatabaseProviderConnection
QgsAbstractDatabaseProviderConnection.SqlLayerDefinitionCapabilities.baseClass = QgsAbstractDatabaseProviderConnection
SqlLayerDefinitionCapabilities = QgsAbstractDatabaseProviderConnection # dirty hack since SIP seems to introduce the flags in module
QgsAbstractDatabaseProviderConnection.SqlKeywordCategory.baseClass = QgsAbstractDatabaseProviderConnection
Expand Up @@ -355,6 +355,20 @@ This information is calculated from the geometry columns types.
typedef QFlags<QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability> SqlLayerDefinitionCapabilities;


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


QgsAbstractDatabaseProviderConnection( const QString &name );
%Docstring
Creates a new connection with ``name`` by reading its configuration from the settings.
Expand Down Expand Up @@ -659,6 +673,17 @@ Returns a list of native types supported by the connection.
Returns the provider key.

.. versionadded:: 3.16
%End

virtual QMap<QgsAbstractDatabaseProviderConnection::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.20
%End

protected:
Expand Down
22 changes: 22 additions & 0 deletions python/gui/auto_generated/codeeditors/qgscodeeditorsql.sip.in
Expand Up @@ -51,6 +51,28 @@ Set field names to ``fieldNames`` to be added to the lexer API.
QStringList fieldNames() const;
%Docstring
Return field names from the lexer API.
%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.20
%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.20
%End

protected:
Expand Down
1 change: 1 addition & 0 deletions python/gui/auto_generated/qgsqueryresultwidget.sip.in
Expand Up @@ -97,6 +97,7 @@ Emitted when the first batch of results has been fetched.
If the query returns no results this signal is not emitted.
%End


};

/************************************************************************
Expand Down
456 changes: 456 additions & 0 deletions src/core/providers/ogr/qgsgeopackageproviderconnection.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/core/providers/ogr/qgsgeopackageproviderconnection.h
Expand Up @@ -82,6 +82,7 @@ class QgsGeoPackageProviderConnection : public QgsAbstractDatabaseProviderConnec
QIcon icon() const override;
QList<QgsVectorDataProvider::NativeType> nativeTypes() const override;
QgsFields fields( const QString &schema, const QString &table ) const override;
QMap<QgsAbstractDatabaseProviderConnection::SqlKeywordCategory, QStringList> sqlDictionary() override;

private:

Expand All @@ -91,7 +92,6 @@ class QgsGeoPackageProviderConnection : public QgsAbstractDatabaseProviderConnec
//! Returns PK name for table
QString primaryKeyColumnName( const QString &table ) const;


};


Expand Down

0 comments on commit 27eb574

Please sign in to comment.