Skip to content

Commit f454827

Browse files
committed
Explain why the workaround for GPKG/SQLite is necessary
I've talked to Even for this one
1 parent 5d7a7ac commit f454827

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/providers/ogr/qgsogrprovider.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -3622,6 +3622,9 @@ QSet<QVariant> QgsOgrProvider::uniqueValues( int index, int limit ) const
36223622
QByteArray sql = "SELECT DISTINCT " + quotedIdentifier( textEncoding()->fromUnicode( fld.name() ) );
36233623

36243624
// GPKG/SQLite fid
3625+
// For GPKG an SQLITE drivers PK fields are not exposed as real fields, (and OGR_F_GetFID only
3626+
// works with GPKG), so we are adding an extra column that will become index 0
3627+
// See https://issues.qgis.org/issues/21311
36253628
if ( ( mGDALDriverName == QLatin1String( "GPKG" ) || mGDALDriverName == QLatin1String( "SQLite" ) )
36263629
&& mFirstFieldIsFid && index == 0 )
36273630
{
@@ -3649,7 +3652,6 @@ QSet<QVariant> QgsOgrProvider::uniqueValues( int index, int limit ) const
36493652
while ( f.reset( l->GetNextFeature() ), f )
36503653
{
36513654
uniqueValues << ( OGR_F_IsFieldSetAndNotNull( f.get(), 0 ) ? convertValue( fld.type(), textEncoding()->toUnicode( OGR_F_GetFieldAsString( f.get(), 0 ) ) ) : QVariant( fld.type() ) );
3652-
36533655
if ( limit >= 0 && uniqueValues.size() >= limit )
36543656
break;
36553657
}

0 commit comments

Comments
 (0)