-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project List API updates for UCM Desktop #5553
Draft
ChrisPenner
wants to merge
8
commits into
trunk
Choose a base branch
from
cp/project-list-updates
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
ChrisPenner
force-pushed
the
cp/project-list-updates
branch
from
January 21, 2025 20:11
8ab42ff
to
5017678
Compare
ChrisPenner
commented
Jan 21, 2025
Comment on lines
-2277
to
-2302
-- | Escape special characters for "LIKE" matches. | ||
-- | ||
-- Prepared statements prevent sql injection, but it's still possible some user | ||
-- may be able to craft a query using a fake "hash" that would let them see more than they | ||
-- ought to. | ||
-- | ||
-- You still need to provide the escape char in the sql query, E.g. | ||
-- | ||
-- @@ | ||
-- SELECT * FROM table | ||
-- WHERE txt LIKE ? ESCAPE '\' | ||
-- @@ | ||
-- | ||
-- >>> likeEscape '\\' "Nat.%" | ||
-- "Nat.\%" | ||
likeEscape :: Char -> Text -> Text | ||
likeEscape '%' _ = error "Can't use % or _ as escape characters" | ||
likeEscape '_' _ = error "Can't use % or _ as escape characters" | ||
likeEscape escapeChar pat = | ||
flip Text.concatMap pat \case | ||
'%' -> Text.pack [escapeChar, '%'] | ||
'_' -> Text.pack [escapeChar, '_'] | ||
c | ||
| c == escapeChar -> Text.pack [escapeChar, escapeChar] | ||
| otherwise -> Text.singleton c | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to Unison.Sqlite.Utils
ChrisPenner
commented
Jan 21, 2025
Comment on lines
+94
to
+106
initializeCurrentProjectPath :: ProjectId -> ProjectBranchId -> [NameSegment] -> Sqlite.Transaction () | ||
initializeCurrentProjectPath projId branchId path = do | ||
Sqlite.execute | ||
[Sqlite.sql| DELETE FROM current_project_path |] | ||
Sqlite.execute | ||
[Sqlite.sql| | ||
INSERT INTO current_project_path(project_id, branch_id, path) | ||
VALUES (:projId, :branchId, :jsonPath) | ||
|] | ||
where | ||
jsonPath :: Text | ||
jsonPath = | ||
Text.Lazy.toStrict (Aeson.encodeToLazyText $ NameSegment.toUnescapedText <$> path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Froze this code via copy-pasta since it's part of a migration and shouldn't change.
1 task
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.
Overview
Resolves:
Handles:
Implementation notes
last_accessed
unix epoch column to theproject_branch
which is set whensetCurrentProjectPath
is called (which is whenever the userswitch
es).likeEscape
there.unison-share-api
for UCM local queries, since these will likely be pretty different than UCM's internal queries over time. If we'd really prefer ALL queries be in the same module I can move it.Interesting/controversial decisions
How do we want to organize query modules and things for UCM Desktop?
Test coverage
Updated api transcript tests.