Skip to content
Permalink
Browse files

Fix storing attribute of feature with negative identifier and test

The test was also bogus in that it expected an inappropriate FID.
  • Loading branch information
strk committed Jun 9, 2016
1 parent 92dda42 commit 9a96414444558a3c0c7a0edb8a428e5f64be94ba
@@ -718,14 +718,17 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int
case pktInt:
case pktUint64:
fid = mConn->getBinaryInt( queryResult, row, col++ );
if ( mSource->mPrimaryKeyType == pktInt )
{
fid = QgsPostgresUtils::int32pk_to_fid( fid );
}
if ( !subsetOfAttributes || fetchAttributes.contains( mSource->mPrimaryKeyAttrs.at( 0 ) ) )
{
feature.setAttribute( mSource->mPrimaryKeyAttrs[0], fid );
}
if ( mSource->mPrimaryKeyType == pktInt )
{
// NOTE: this needs be done _after_ the setAttribute call
// above as we want the attribute value to be 1:1 with
// database value
fid = QgsPostgresUtils::int32pk_to_fid( fid );
}
break;

case pktFidMap:
@@ -169,7 +169,7 @@ def test_query_attribute(dbconn, query, att, val, fidval):
self.assertEqual(f.attributes()[att_idx], val)
#self.assertEqual(f.id(), val)
self.assertEqual(count, 1)
test_query_attribute(self.dbconn, '(SELECT -1::int4 i, NULL::geometry(Point) g)', 'i', -1, 1)
test_query_attribute(self.dbconn, '(SELECT -1::int4 i, NULL::geometry(Point) g)', 'i', -1, 4294967295)
test_query_attribute(self.dbconn, '(SELECT -1::int2 i, NULL::geometry(Point) g)', 'i', -1, 1)
test_query_attribute(self.dbconn, '(SELECT -1::int8 i, NULL::geometry(Point) g)', 'i', -1, 1)
test_query_attribute(self.dbconn, '(SELECT -65535::int8 i, NULL::geometry(Point) g)', 'i', -65535, 1)

0 comments on commit 9a96414

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