Skip to content

Commit

Permalink
[BUGFIX] [PostgreSQL] Properly take into account 'name' type
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Oct 20, 2024
1 parent 36694c1 commit ec7c865
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ bool QgsPostgresProvider::loadFields()
// PG 12 returns "name" type for some system table fields (e.g. information_schema.tables)
else if ( fieldTypeName == QLatin1String( "name" ) )
{
fieldSubType = QVariant::String;
fieldType = QVariant::String;
fieldSize = 63;
}
else
Expand Down
9 changes: 9 additions & 0 deletions tests/src/python/test_provider_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -3355,6 +3355,15 @@ def testPktLowerCase(self):
cur.execute(sql_pk)
self.assertEqual(cur.fetchall(), [('dep', 'character varying')])

def testNameType(self):

vl = QgsVectorLayer(self.dbconn + ' sslmode=disable key=\'"table_catalog","table_schema","table_name"\' table="information_schema"."tables" () sql=', 'test', 'postgres')
self.assertTrue(vl.isValid())

feat = next(vl.getFeatures())
self.assertTrue(feat.isValid())
self.assertIsNotNone(feat.attributes()[0])


class TestPyQgsPostgresProviderCompoundKey(QgisTestCase, ProviderTestCase):

Expand Down

0 comments on commit ec7c865

Please sign in to comment.