Repository navigation
refactor(db): move the flag-validation maps into the view table - #259
Merged
Merged
Conversation
Follows #240, which folded the four maps that shape a view's SQL into one `viewSpec` and left these two out as a separate question: they gate flag validation at the CLI boundary rather than composing SQL. Leaving them meant adding a view still touched three places, and nothing tied their keys to the table, so a view could be added with its SQL in place and its flags forgotten. `dateFilterableViews` and `viewsWithoutProjectFilter` are now `supportsDateFilter` and `rejectsProjectFilter` on the spec. `DateFilterableView` and `ProjectFilterableView` read the table. Adding a view is one entry and nothing else. `rejectsProjectFilter` is stated in the negative, which is what preserves the behaviour for a name that is not a view at all: the map it replaces listed the views that refuse the filter, so an unknown name was filterable, and a zero spec keeps it that way. `supportsDateFilter` is positive for the same reason in reverse — an unknown name was not date-filterable and still is not. No SQL changes, and the golden file is untouched. `TestDateFilterableView` and `TestProjectFilterableView` pin both answers against expectations spelled out in the test rather than derived from the table; the former grew the `repeating` case, so between them the two now cover all ten views and an unknown name. Checked against origin/main directly as well: all three view flags give the same answer for every view and for a name that is not one.
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.
Follows #240.
Why
#240 folded the four maps that shape a view's SQL into one
viewSpecand deliberately left two out, because they gate flag validation at the CLI boundary rather than composing SQL. That left adding a view touching three places, and nothing tied the two maps' keys to the table, so a view could be added with its SQL in place and its flags forgotten.What changed
dateFilterableViewsandviewsWithoutProjectFilterare nowsupportsDateFilterandrejectsProjectFilteron the spec, set on the six views that need them.DateFilterableViewandProjectFilterableViewread the table. Adding a view is now one entry and nothing else.rejectsProjectFilteris the one flag stated in the negative, and that is what preserves the answer for a name that is not a view at all. The map it replaces listed the views that refuse the filter, so an unknown name came back filterable; a zero spec keeps it that way.supportsDateFilteris positive for the mirror-image reason: an unknown name was not date-filterable and still is not.Verification
No SQL changes, and
testdata/list_query_golden.txtis untouched — the two hundred view-and-filter combinations #240 pinned are unaffected, which is the point.TestDateFilterableViewandTestProjectFilterableViewpin both answers against expectations spelled out in the test rather than derived from the table, so a spec that loses a flag fails rather than quietly redefining what is expected. The date test gained therepeatingcase it was missing, so between them the two now cover all ten views plus a name that is not one.Checked against
origin/maindirectly as well, rather than only through the tests: all three view flags — date-filterable, project-filterable and completable — give the same answer for every one of the ten views and for an unknown name.Review
/code-review --fixat high effort found no correctness bugs and two low points, both taken.TestDateFilterableViewpinned two hand-written lists of view names where its two siblings iterate the table, so a view added with the date flag set would have gone untested; it now walksviewsand keeps its explicit unknown-name case. ThesupportsDateFilterdoc explained four of the five excluded views and omittedrepeating.I rewrote the second fix rather than taking it as offered. It filled the gap with a claim about what a template's
startDatemeans — the recurrence rule's anchor rather than a scheduled date — and I could not verify that: the database this work was measured against holds no repeating items in either recurrence column, so there was nothing to check it against. The comments in this file carry measurements and get cited as authority, so the doc now gives the reason that follows from what the view is (it lists templates, not scheduled items, and the instances a template generates are ordinary rows in the dated views) and says plainly that the templatestartDatequestion was not measured.