@@ -423,7 +423,7 @@ QString QgsSpatiaLiteFeatureIterator::whereClauseRect()
423
423
mbrFilter += QStringLiteral ( " ymax >= %1" ).arg ( qgsDoubleToString ( mFilterRect .yMinimum () ) );
424
424
QString idxName = QStringLiteral ( " idx_%1_%2" ).arg ( mSource ->mIndexTable , mSource ->mIndexGeometry );
425
425
whereClause += QStringLiteral ( " %1 IN (SELECT pkid FROM %2 WHERE %3)" )
426
- .arg ( quotedPrimaryKey ( ),
426
+ .arg ( QStringLiteral ( " ROWID " ),
427
427
QgsSqliteUtils::quotedIdentifier ( idxName ),
428
428
mbrFilter );
429
429
}
@@ -432,7 +432,7 @@ QString QgsSpatiaLiteFeatureIterator::whereClauseRect()
432
432
// using the MbrCache spatial index
433
433
QString idxName = QStringLiteral ( " cache_%1_%2" ).arg ( mSource ->mIndexTable , mSource ->mIndexGeometry );
434
434
whereClause += QStringLiteral ( " %1 IN (SELECT rowid FROM %2 WHERE mbr = FilterMbrIntersects(%3))" )
435
- .arg ( quotedPrimaryKey ( ),
435
+ .arg ( QStringLiteral ( " ROWID " ),
436
436
QgsSqliteUtils::quotedIdentifier ( idxName ),
437
437
mbr ( mFilterRect ) );
438
438
}
@@ -506,7 +506,7 @@ bool QgsSpatiaLiteFeatureIterator::getFeature( sqlite3_stmt *stmt, QgsFeature &f
506
506
{
507
507
if ( ic == 0 )
508
508
{
509
- if ( mHasPrimaryKey )
509
+ if ( mHasPrimaryKey && sqlite3_column_type ( stmt, ic ) == SQLITE_INTEGER )
510
510
{
511
511
// first column always contains the ROWID (or the primary key)
512
512
QgsFeatureId fid = sqlite3_column_int64 ( stmt, ic );
0 commit comments