Skip to content
Permalink
Browse files

Merge pull request #36128 from qgis-bot/backport-36124-to-release-3_12

[Backport release-3_12] Fixed fetching NULL bigint pgsql attributes. Fixes #36011
  • Loading branch information
m-kuhn committed May 1, 2020
2 parents 3e21da8 + 57bde67 commit 9cfa28515183eb6f074875f7d7d38ff7c7a88db2
@@ -859,7 +859,14 @@ void QgsPostgresFeatureIterator::getFeatureAttribute( int idx, QgsPostgresResult
}
case QVariant::LongLong:
{
v = QgsPostgresProvider::convertValue( fld.type(), fld.subType(), QString::number( mConn->getBinaryInt( queryResult, row, col ) ), fld.typeName() );
if ( ::PQgetisnull( queryResult.result(), row, col ) )
{
v = QVariant( QVariant::LongLong );
}
else
{
v = QgsPostgresProvider::convertValue( fld.type(), fld.subType(), QString::number( mConn->getBinaryInt( queryResult, row, col ) ), fld.typeName() );
}
break;
}
default:
@@ -441,6 +441,10 @@ def testNonPkBigintField(self):
bigint_with_default_idx = vl.fields().lookupField('bigint_attribute_def')
self.assertEqual(f.attributes()[bigint_with_default_idx], 42)

# check if NULL values are correctly read
bigint_def_null_idx = vl.fields().lookupField('bigint_attribute')
self.assertEqual(f.attributes()[bigint_def_null_idx], NULL)

# check if we can overwrite a default value
vl.startEditing()
vl.changeAttributeValue(f.id(), bigint_with_default_idx, 43)

0 comments on commit 9cfa285

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