Conversation
…inked SQL folders
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
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.
Summary
Version history for saved queries, and Git status, history and Discard for files in a linked SQL folder.
Fixes #2505
What was missing
A saved query was one row in
sql_favorites.dbthat every edit overwrote, and nothing in the app knew about Git. A linked folder inside a repository showed no status, no diff and no way back to an earlier version.Saved queries
favorite_versionstable, filled by SQLite triggers onfavorites. When a query's SQL changes, the trigger stores the text it replaced and keeps the newest 50 for that query. Deleting the query deletes them.INSERT … ON CONFLICT DO UPDATEfiresUPDATEtriggers, measured on SQLite 3.54). An edit lost to a sync echo (a pre-existing bug, reported separately) now leaves a recoverable version.favorite_query_timesholds when each query's SQL was last written, backfilled fromupdated_atfor existing queries, so a rename or keyword change does not move the date shown on the next version.INSERT OR REPLACEtakes the outer statement's conflict policy, and under the sync upsert that aborted the whole write (measured, and caught by a test). The trigger bodies delete then insert instead.migrateIfNeeded(): the v1→v2 migration renames and dropsfavorites, which would drop triggers created before it.UPDATE … SET query, updated_atand marks the query for sync. The text it replaces becomes a version itself, so a restore can be undone the same way.Linked SQL folders in a Git repository
isExecutableFileand never run to probe: Homebrew, the developer directory read from/var/db/xcode_select_link, the Command Line Tools, then Xcode./usr/bin/gitandxcrunare never used, because on a Mac without the Command Line Tools the shim opens the installer.--no-optional-locks --no-pager --literal-pathspecs,core.fsmonitor=false,core.hooksPath=/dev/null,color.ui=never,log.showSignature=false,safe.bareRepository=explicit. InheritedGIT_DIR-style variables are stripped.GIT_OPTIONAL_LOCKS=0,GIT_TERMINAL_PROMPT=0andGIT_NO_LAZY_FETCH=1are set.statusdoes not rewrite.git/index(inode and mtime checked in a test).status --porcelain=v2 -zplusls-files -z --full-name, run from the linked folder and mapped throughrev-parse --show-prefix. An ignored file shows no letter and gets no Git commands. Everyurecord counts as a conflict, includingAA.SQLFolderWatcherno longer rescans every SQL file when an event only touches.git.log --follow -z --name-statuskeeps the path each commit had, so a version reads correctly across renames. A commit that deleted the file is skipped, since it has no version to show. Commit ids that are not 40 or 64 hex characters are dropped before they can reach acat-fileargument, which also carries--end-of-options.cat-file blob <commit>:<path>, or:./<file>for the index) and write it with the same atomic write the editor's save uses. So no smudge or process filter runs on a user action, and the bytes written are the bytes the preview showed. A Git LFS pointer is refused with a message.status, so files marked assume-unchanged or skip-worktree still ask first. Discard restores the index version, so staged work is kept, and it re-reads the index at the moment of writing so a staging change during the prompt aborts the write.One History tab for both
TabType.versionHistory, restored on relaunch the way the object-source tab is. The version list usesFieldDrivenList, next to Changes (split or unified diff) and Content (the read-onlyObjectSourceView).Cmd+R) reloads the tab.TextDiffViewis lifted out ofStructureDefinitionDiffView, which now renders through it, rather than adding a fourth diff renderer.Not gated behind Pro: Linked SQL Folders and saved queries are free today.
Before / After
There is no before for the History tab: it is new. Before this change the sidebar row for a linked file showed no status letter and its menu had no Git commands; that state was not captured separately.
After, a linked file with uncommitted changes (the top row compares HEAD with the file on disk;
MandUletters in the sidebar):After, a commit selected in dark mode, compared with the current version:
Security
Automatic
git statusin a linked repository runs that repository's own clean filters, asgit statusin Terminal would. The docs page carries a warning to link only trusted repositories. Nothing in this change runs a smudge filter, hook, fsmonitor, pager, external diff, textconv or signature program. A security review built a repository whose config wires up each of those and ran the exact commands against it: only the documented clean filter fired, and only duringstatus.Verification
git;SavedQueryHistoryUITests: create a saved query, edit it, Show History, restore.