Skip to content

Commit

Permalink
Merge pull request #43529 from elpaso/bugfix-pg-identity-nextval
Browse files Browse the repository at this point in the history
Fix PG IDENTITY default value clause
  • Loading branch information
elpaso committed Jun 3, 2021
2 parents 96f5171 + d4f5d53 commit ce2f9b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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 ) );
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/test_provider_postgres.py
Expand Up @@ -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
Expand Down

0 comments on commit ce2f9b8

Please sign in to comment.