Skip to content
Permalink
Browse files

Merge pull request #38336 from m-kuhn/sqlite_dqs

Use valid sql for unique value detection in sqlite
  • Loading branch information
m-kuhn committed Sep 6, 2020
2 parents c0ebc68 + df81c51 commit dd3cc1283f4d3dbdfea801751ef5bd70d18bd3cd
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/core/qgssqliteutils.cpp
@@ -126,9 +126,9 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &
QSet<QString> uniqueFieldsResults;
char *zErrMsg = 0;
std::vector<std::string> rows;
QByteArray tableNameUtf8 = quotedIdentifier( tableName ).toUtf8();
QByteArray tableNameUtf8 = tableName.toUtf8();
QString sql = qgs_sqlite3_mprintf( "select sql from sqlite_master "
"where type='table' and name=%q", tableNameUtf8.constData() );
"where type='table' and name='%q'", tableNameUtf8.constData() );
auto cb = [ ](
void *data /* Data provided in the 4th argument of sqlite3_exec() */,
int /* The number of columns in row */,
@@ -174,7 +174,7 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &

// Search indexes:
sql = qgs_sqlite3_mprintf( "SELECT sql FROM sqlite_master WHERE type='index' AND"
" tbl_name='%q' AND sql LIKE 'CREATE UNIQUE INDEX%%'", tableNameUtf8.constData() );
" tbl_name='%q' AND sql LIKE 'CREATE UNIQUE INDEX%%'", tableNameUtf8.constData() );
rc = sqlite3_exec( connection, sql.toUtf8(), cb, ( void * )&rows, &zErrMsg );
if ( rc != SQLITE_OK )
{

0 comments on commit dd3cc12

Please sign in to comment.
You can’t perform that action at this time.