Fix PostgreSQL DSN: reconstruct full URI in store, keep drivers consistent#6
Open
pubmatt wants to merge 2 commits into
Open
Fix PostgreSQL DSN: reconstruct full URI in store, keep drivers consistent#6pubmatt wants to merge 2 commits into
pubmatt wants to merge 2 commits into
Conversation
Ensures the PostgreSQL connection string is correctly formatted as a full URI (e.g., `postgres://...`) when passed to the GORM dialector. This addresses the PostgreSQL driver's expectation for a URI-prefixed DSN, preventing connection issues.
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
Fixes PostgreSQL connections by ensuring the store passes a full
postgres://...URI to the driver, and keeps all DB drivers using the same pattern (no DSN manipulation inside drivers).Problem
The store splits the DSN on
://and passes only the part after the scheme toGormDialector. The PostgreSQL driver expects a full URI (postgres://user:...@host:5432/dbname?sslmode=...). Passing only the fragment caused connection failures or incorrect parsing.Solution
pkg/stor/store.go): AfteraddDialectSpecificParams, build the DSN passed toGormDialector. Forpostgres, use the full URI (dialect + "://" + cnx); for MySQL and SQLite, keep passingcnxas before. PostgreSQL is handled in the same place as other dialect-specific logic.pkg/stor/driver_pgsql.go): Usepostgres.Open(cnx)only, with no string prepending, matchingdriver_mysql.goanddriver_sqlite.go.Result
-tags PGSQLand apostgres://...DSN.Open(cnx)only.