Configure search_path for PostgreSQL connections#274
Merged
Conversation
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>
c70f122 to
08c7148
Compare
bjoernhaeuser
approved these changes
Oct 30, 2025
Member
bjoernhaeuser
left a comment
There was a problem hiding this comment.
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.
Member
Author
noted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Configures the PostgreSQL search_path runtime parameter in both
NewPoolandMigratefunctions 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