Skip to content

Commit dd3cc12

Browse files
authoredSep 6, 2020
Merge pull request #38336 from m-kuhn/sqlite_dqs
Use valid sql for unique value detection in sqlite
2 parents c0ebc68 + df81c51 commit dd3cc12

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/core/qgssqliteutils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &
126126
QSet<QString> uniqueFieldsResults;
127127
char *zErrMsg = 0;
128128
std::vector<std::string> rows;
129-
QByteArray tableNameUtf8 = quotedIdentifier( tableName ).toUtf8();
129+
QByteArray tableNameUtf8 = tableName.toUtf8();
130130
QString sql = qgs_sqlite3_mprintf( "select sql from sqlite_master "
131-
"where type='table' and name=%q", tableNameUtf8.constData() );
131+
"where type='table' and name='%q'", tableNameUtf8.constData() );
132132
auto cb = [ ](
133133
void *data /* Data provided in the 4th argument of sqlite3_exec() */,
134134
int /* The number of columns in row */,
@@ -174,7 +174,7 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &
174174

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

0 commit comments

Comments
 (0)
Please sign in to comment.