Skip to content

Commit

Permalink
[spatialite] Fix corrupted default attribute values when fields
Browse files Browse the repository at this point in the history
are loaded using gaiaVectorLayer
  • Loading branch information
nyalldawson committed Sep 27, 2022
1 parent a0fb44b commit f1f74ff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -759,15 +759,19 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
int ret = sqlite3_get_table( mSqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg );
if ( ret == SQLITE_OK )
{
int realFieldIndex = 0;
for ( int i = 1; i <= rows; i++ )
{
QString name = QString::fromUtf8( results[( i * columns ) + 1] );

if ( name.compare( mGeometryColumn, Qt::CaseInsensitive ) == 0 )
continue;

insertDefaultValue( realFieldIndex, QString::fromUtf8( results[( i * columns ) + 4] ) );
const QString defaultValue = QString::fromUtf8( results[( i * columns ) + 4] );
const int realFieldIndex = mAttributeFields.lookupField( name );
if ( realFieldIndex >= 0 )
{
insertDefaultValue( realFieldIndex, defaultValue );
}

QString pk = results[( i * columns ) + 5];
QString type = results[( i * columns ) + 2];
Expand Down Expand Up @@ -798,7 +802,6 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
else
mPrimaryKey.clear();
mPrimaryKeyAttrs << i - 1;
realFieldIndex += 1;
}
}

Expand Down

0 comments on commit f1f74ff

Please sign in to comment.