feat: named saved queries + lazy connection pool (0.17.0)#56
Merged
Conversation
- Add :save / :load / :run-saved commands for per-connection named queries persisted under <data_dir>/queries/<conn>/<name>.sql. :load inserts at the cursor; :run-saved [name] reuses the existing query pipeline so placeholder prompts still fire. Bare :run-saved opens an overlay picker. - Switch postgres + mysql pools to connect_lazy with min_connections(0) and idle_timeout(60s), and only pin a session connection while a transaction is open (tx state derived via sqlparser). :reset now closes and rebuilds the pool to force-drop every backend connection. Sqlite keeps the same tx-aware release but no idle-timeout (would drop :memory: data). - Bump to 0.17.0.
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
:save <name>,:load <name>(inserts at cursor),:run-saved [name](bare form opens a picker overlay). Stored as one.sqlfile per query under<data_dir>/queries/<conn>/<name>.sql. Overwrite confirms via an Enter/Esc bottom-bar prompt; placeholders still bounce through the existing params popup because:run-saveddispatches throughquery::dispatch_query.connect_lazy+min_connections(0)+idle_timeout(60s). The pinned session conn is now held only while a transaction is open — transitions are derived fromsqlparser(BEGIN/COMMIT/ROLLBACK).:resetswaps in a fresh pool andclose()s the old one to force-disconnect every backend. SQLite gets the same tx-aware session release but keeps its pool intact so:memory:databases don't evaporate.Test plan
cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test(619 tests pass locally):memory:connection,:save smokewith aSELECT 1 WHERE x = :id;in the buffer,:run-saved smokeand verify the params prompt fires:run-saved(no name) → picker opens; Enter dispatches; Esc closes:save smokeagain → overwrite confirm overlay; test both Enter and EscBEGIN; SELECT 1;then idle 70s — backend should be dropped (checkpg_stat_activity);:resetafterBEGINforce-kills the session backend