pg: fix list_key_versions interpreting keys as patterns - #114
Merged
tankyleo merged 1 commit intoSep 24, 2026
Merged
Conversation
|
I've assigned @tankyleo as a reviewer! |
Contributor
Author
|
cc @tnull (can't add reviewers in the sidebar 😢) |
tankyleo
reviewed
Sep 23, 2026
tankyleo
left a comment
Contributor
There was a problem hiding this comment.
thanks sorry for the delay this needs a rebase
Using `key LIKE $3` unescaped tells Postgres to interpret the requested key prefix as a pattern, which means %, _, and \ are interpreted as wildcards and character escapes in the original prefix rather the actual intended literal prefix. This means a `list_key_versions(key="foo_bar", ..)` actually includes `foo1bar`, which definitely does not seem intentional. A better approach is to just use `starts_with(key, $3)`, which the query planner understands better and doesn't require us to do any escaping.
phlip9
force-pushed
the
phlip9/fix-list-key-versions
branch
from
September 24, 2026 01:59
e833d09 to
3ae3390
Compare
tankyleo
approved these changes
Sep 24, 2026
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.
Using
key LIKE $3unescaped tells Postgres to interpret the requested key prefix as a pattern, which means %, _, and \ are interpreted as wildcards and character escapes in the original prefix rather the actual intended literal prefix.This means a
list_key_versions(key="foo_bar", ..)actually includesfoo1bar, which definitely does not seem intentional.A better approach is to just use
starts_with(key, $3), which the query planner understands better and doesn't require any escaping.