QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
19#include "qgssqliteutils.h"
20
22
23QString 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
31QString QgsProviderSqlQueryBuilder::quoteIdentifier( const QString &identifier ) const
32{
33 // TODO: handle backend-specific identifier quoting...
34 return QgsSqliteUtils::quotedIdentifier( identifier );
35}
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.