Skip to content
Permalink
Browse files

Merge pull request #36124 from espinafre/fix_pg_bigint_default

Fixed fetching NULL bigint pgsql attributes. Fixes #36011
  • Loading branch information
m-kuhn committed May 1, 2020
2 parents 347d048 + 5202d08 commit 253c706b5cdb0f5106453103cf61540c4d0c98a4
@@ -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 253c706

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