Skip to content
Permalink
Browse files

Fixed fetching NULL bigint pgsql attributes. Fixes #36011

  • Loading branch information
espinafre committed May 1, 2020
1 parent bc3cea9 commit 5202d08db95af8b31b04c21ec46a3b123e541969
@@ -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 5202d08

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