Skip to content
Permalink
Browse files
Merge pull request #43529 from elpaso/bugfix-pg-identity-nextval
Fix PG IDENTITY default value clause
  • Loading branch information
elpaso committed Jun 3, 2021
2 parents 96f5171 + d4f5d53 commit ce2f9b8ed1875b27502d9fbb137eb9b987cbb543
Showing with 3 additions and 1 deletion.
  1. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
  2. +2 −0 tests/src/python/test_provider_postgres.py
@@ -1237,7 +1237,7 @@ bool QgsPostgresProvider::loadFields()
QgsPostgresResult seqResult( connectionRO()->PQexec( seqSql ) );
if ( seqResult.PQntuples() == 1 )
{
defValMap[tableoid][attnum] = QStringLiteral( "nextval(%1::regclass)" ).arg( quotedIdentifier( seqName ) );
defValMap[tableoid][attnum] = QStringLiteral( "nextval(%1::regclass)" ).arg( quotedValue( seqName ) );
}
}

@@ -2383,6 +2383,8 @@ def testIdentityPk(self):
feature.setGeometry(geom)
self.assertTrue(vl.dataProvider().addFeature(feature))

self.assertEqual(vl.dataProvider().defaultValueClause(0), "nextval('b29560_gid_seq'::regclass)")

del (vl)

# Verify

0 comments on commit ce2f9b8

Please sign in to comment.