QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsprovidersqlquerybuilder.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprovidersqlquerybuilder.cpp
3begin : August 2022
4copyright : (C) 2022 by Nyall Dawson
5email : 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
18#include "qgssqliteutils.h"
19
21
22QString QgsProviderSqlQueryBuilder::createLimitQueryForTable( const QString &schema, const QString &name, int limit ) const
23{
24 if ( schema.isEmpty() )
25 return QStringLiteral( "SELECT * FROM %1 LIMIT %2" ).arg( quoteIdentifier( name ) ).arg( limit );
26 else
27 return QStringLiteral( "SELECT * FROM %1.%2 LIMIT %3" ).arg( quoteIdentifier( schema ), quoteIdentifier( name ) ).arg( limit );
28}
29
30QString QgsProviderSqlQueryBuilder::quoteIdentifier( const QString &identifier ) const
31{
32 // TODO: handle backend-specific identifier quoting...
33 return QgsSqliteUtils::quotedIdentifier( identifier );
34}
virtual ~QgsProviderSqlQueryBuilder()
virtual QString quoteIdentifier(const QString &identifier) const
Returns a properly quoted version of a table/schema identifier.
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,...
static QString quotedIdentifier(const QString &identifier)
Returns a properly quoted version of identifier.