Repository navigation
fix(lookup): match a task reference and a search query literally - #268
Merged
Merged
Conversation
FindTasksByTitle and SearchTasks matched with LIKE and used the caller's text as the pattern. So `_` stood for any character and `%` for any run of them in a reference the user typed. GetTask falls back to FindTasksByTitle and acts on a lookup that matches exactly one row, so `things complete '20_30 review'` could resolve to, and complete, a task called "20:30 review" — a status write on a task the user never named. #266 fixed the same gap for the list filters. Both now escape the value and declare ESCAPE, from the constant #266 introduced. Substring matching is unchanged: the wildcards either side are the CLI's, and only the characters inside the value stop being pattern syntax. Matching stays case-insensitive, as it has always been. On the live database `things search '50%'` returned 45 rows against no item containing that text at all; it now returns none, and `search 'review'` returns the same 129 either way. The regression tests are the part worth reading. My first versions passed against the unfixed code, which the review caught by reverting the fix and running them. Both were vacuous for the same two reasons: GetTask resolves an exact title before the LIKE is reached, so seeding the exact title never exercised the path; and LIKE wildcards act on the pattern, not the stored value, so putting the underscore in the seeded title tested nothing. They are rebuilt around the real failure — resolve a reference that must miss, then a substring that forces the LIKE path — and now fail against unfixed code with pointed messages, which I confirmed by reverting. Nothing documented changes: wildcards were never offered for `<task>` or `search`. The README, the site and the bundled skill now say so. Closes #267
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.
Closes #267
Release note
A task reference and a search query now match literally —
%and_are characters to find, not wildcards — sothings completecan no longer resolve to a task you did not name.What changed
FindTasksByTitleandSearchTasksmatched withLIKEand used the caller's text as the pattern, so_stood for any character and%for any run of them.GetTaskfalls back toFindTasksByTitleand acts on a lookup that matches exactly one row, sothings complete '20_30 review'could resolve to, and complete, a task called20:30 review. #266 fixed the same gap for the list filters; this is the more dangerous half, because a write command acts on the result.Both now escape the value and declare
ESCAPE, from the constant #266 introduced. Substring matching is unchanged — the wildcards either side are the CLI's, and only the characters inside the value stop being pattern syntax. Matching stays case-insensitive.Measured on the live database
search '50%'50%search 'review'My first regression tests were worthless, and that is the part worth reading
Both passed against the unfixed code.
/code-reviewcaught it by reverting the fix and running them. Two separate mistakes, both easy to repeat:GetTaskresolves an exact title before theLIKEis ever reached, so seeding the exact title under test never exercised the path.LIKEwildcards act on the pattern, not on the stored value. I put the underscore in the seeded title and queried plain text, which tests nothing.They are rebuilt around the real failure: resolve a reference that must miss, then resolve a substring that forces the
LIKEpath. I revertedtasks.goand confirmed they now fail, rather than taking the review's word:Docs
Nothing documented changes, because wildcards were never offered for
<task>orsearch. The README, the site's Searching and Inspecting sections, and the bundled skill now say the matching is literal, so the absence is stated rather than assumed.make testandmake lintare clean;hugobuilds the site.