QGIS API Documentation
3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
src
core
providers
qgsprovidersqlquerybuilder.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsprovidersqlquerybuilder.cpp
3
begin : August 2022
4
copyright : (C) 2022 by Nyall Dawson
5
email : nyall dot dawson at gmail dot com
6
***************************************************************************/
7
8
/***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
17
#include "
qgsprovidersqlquerybuilder.h
"
18
19
#include "
qgssqliteutils.h
"
20
21
QgsProviderSqlQueryBuilder::~QgsProviderSqlQueryBuilder
() =
default
;
22
23
QString
QgsProviderSqlQueryBuilder::createLimitQueryForTable
(
const
QString &schema,
const
QString &name,
int
limit )
const
24
{
25
if
( schema.isEmpty() )
26
return
QStringLiteral(
"SELECT * FROM %1 LIMIT %2"
).arg(
quoteIdentifier
( name ) ).arg( limit );
27
else
28
return
QStringLiteral(
"SELECT * FROM %1.%2 LIMIT %3"
).arg(
quoteIdentifier
( schema ),
quoteIdentifier
( name ) ).arg( limit );
29
}
30
31
QString
QgsProviderSqlQueryBuilder::quoteIdentifier
(
const
QString &identifier )
const
32
{
33
// TODO: handle backend-specific identifier quoting...
34
return
QgsSqliteUtils::quotedIdentifier
( identifier );
35
}
QgsProviderSqlQueryBuilder::~QgsProviderSqlQueryBuilder
virtual ~QgsProviderSqlQueryBuilder()
QgsProviderSqlQueryBuilder::quoteIdentifier
virtual QString quoteIdentifier(const QString &identifier) const
Returns a properly quoted version of a table/schema identifier.
Definition
qgsprovidersqlquerybuilder.cpp:31
QgsProviderSqlQueryBuilder::createLimitQueryForTable
virtual QString createLimitQueryForTable(const QString &schema, const QString &name, int limit=10) const
Returns a result size limited SQL query string generated for the given schema and table name,...
Definition
qgsprovidersqlquerybuilder.cpp:23
QgsSqliteUtils::quotedIdentifier
static QString quotedIdentifier(const QString &identifier)
Returns a properly quoted version of identifier.
Definition
qgssqliteutils.cpp:266
qgsprovidersqlquerybuilder.h
qgssqliteutils.h
Generated on
for QGIS API Documentation by
1.15.0