Skip to content

Commit

Permalink
Fix PG IDENTITY default value clause
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jun 3, 2021
1 parent fd9fe21 commit d4f5d53
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 d4f5d53

Please sign in to comment.