Skip to content

Conversation

myzktkyk
Copy link

@myzktkyk myzktkyk commented Oct 2, 2025

Description

Fixes #577

This PR adds proper identifier quoting using pq.QuoteIdentifier() for publication names and owner names in all SQL statements within the postgresql_publication resource.

Problem

When setting a publication owner or name containing special characters (e.g., hyphens like tenant-management-user), the resource failed with a syntax error:

Error: could not update publication owner: Error updating publication owner: pq: syntax error at or near "-"

This occurred because identifiers were not properly quoted in SQL statements.

Solution

Added pq.QuoteIdentifier() to all publication and owner name references in:

  • CREATE PUBLICATION statements
  • ALTER PUBLICATION ... OWNER TO statements
  • ALTER PUBLICATION ... ADD/DROP TABLE statements
  • ALTER PUBLICATION ... SET statements (parameter updates)

This aligns the publication resource with the identifier quoting standards already implemented in other resources (database, schema, role, etc.).

Testing

  • ✅ All publication acceptance tests pass, including TestAccPostgresqlPublication_UpdateOwner and TestAccPostgresqlPublication_UpdateName
  • ✅ Tests now validate identifiers with hyphens work correctly

Quote publication and owner names using pq.QuoteIdentifier() in CREATE
and ALTER statements to align with other resources.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to set owner in postgresql_publication

1 participant