@@ -147,6 +147,25 @@ def test_unique(features, num_features):
147147 self .assertTrue (vl .isValid ())
148148 test_unique ([f for f in vl .getFeatures ()], 4 )
149149
150+ # See http://hub.qgis.org/issues/14262
151+ def testSignedIdentifiers (self ):
152+ def test_query_attribute (dbconn , query , att , val , fidval ):
153+ ql = QgsVectorLayer ('%s table="%s" (g) key=\' %s\' sql=' % (dbconn , query .replace ('"' , '\\ "' ), att ), "testgeom" , "postgres" )
154+ print query , att
155+ assert (ql .isValid ())
156+ features = ql .getFeatures ()
157+ att_idx = ql .fieldNameIndex (att )
158+ count = 0
159+ for f in features :
160+ count += 1
161+ self .assertEqual (f .attributes ()[att_idx ], val )
162+ #self.assertEqual(f.id(), val)
163+ self .assertEqual (count , 1 )
164+ test_query_attribute (self .dbconn , '(SELECT -1::int4 i, NULL::geometry(Point) g)' , 'i' , - 1 , 1 )
165+ test_query_attribute (self .dbconn , '(SELECT -1::int2 i, NULL::geometry(Point) g)' , 'i' , - 1 , 1 )
166+ test_query_attribute (self .dbconn , '(SELECT -1::int8 i, NULL::geometry(Point) g)' , 'i' , - 1 , 1 )
167+ test_query_attribute (self .dbconn , '(SELECT -65535::int8 i, NULL::geometry(Point) g)' , 'i' , - 65535 , 1 )
168+
150169
151170if __name__ == '__main__' :
152171 unittest .main ()
0 commit comments