Skip to content

Configure search_path for PostgreSQL connections#274

Merged
svenwltr merged 2 commits intomainfrom
configure-search-path
Oct 30, 2025
Merged

Configure search_path for PostgreSQL connections#274
svenwltr merged 2 commits intomainfrom
configure-search-path

Conversation

@svenwltr
Copy link
Copy Markdown
Member

@svenwltr svenwltr commented Oct 30, 2025

Summary

Configures the PostgreSQL search_path runtime parameter in both NewPool and Migrate functions to use the schema provided via dependency injection. This eliminates the need for fully-qualified table names in SQL queries.

Additionally fixes a SQL injection vulnerability in the schema creation function by properly sanitizing schema names using pgx.Identifier.Sanitize().

🤖 Generated with Claude Code

@svenwltr svenwltr self-assigned this Oct 30, 2025
svenwltr and others added 2 commits October 30, 2025 16:25
Updated both NewPool and Migrate to set the search_path runtime parameter
using the Schema value provided via dependency injection. This allows SQL
queries to use unqualified table names without requiring fully-qualified
schema.table notation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Sanitize schema name in createSchemaIfNotExists to prevent SQL injection attacks. Uses pgx.Identifier.Sanitize() consistent with other schema handling in the package.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@svenwltr svenwltr force-pushed the configure-search-path branch from c70f122 to 08c7148 Compare October 30, 2025 15:37
@svenwltr svenwltr marked this pull request as ready for review October 30, 2025 15:51
@svenwltr svenwltr requested a review from a team as a code owner October 30, 2025 15:51
Copy link
Copy Markdown
Member

@bjoernhaeuser bjoernhaeuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While providing the search-path isn't wrong at all, I always prefer qualified table-names. This allows to copy the queries from a monitoring solution and be able to execute those right away.

@svenwltr
Copy link
Copy Markdown
Member Author

While providing the search-path isn't wrong at all, I always prefer qualified table-names. This allows to copy the queries from a monitoring solution and be able to execute those right away.

echo "* Prefer fully qualified table-names in SQL queries" >> .claude/CLAUDE.md

noted

@svenwltr svenwltr merged commit d813cc3 into main Oct 30, 2025
1 check passed
@svenwltr svenwltr deleted the configure-search-path branch October 30, 2025 19:35
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.

2 participants