Fix whitespace issues in SQLite absolute paths in DATABASE_URL #266
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.
When the DSN is in the form
sqlite:/absolute/path
orsqlite://absolute/path
orsqlite:///absolute/path
, url.Parsewill consider the file path as:
absolute
as the hostnamepath
(and the rest until?
) as the URL path.Instead, when the DSN is in the form "sqlite:", the (relative) file path is stored in the "Opaque" field.
See: https://pkg.go.dev/net/url#URL
While Opaque is not escaped, the URL Path is. So, in absolute paths the full file path is being escaped as if it was an URL path.
This commit works around this behavior in
ConnectionString()
(sqlite.go
) so that the return string is always a correct (url-unescaped) file path.Fixes #264 .