fix(repl): expand :varname aliases before checking for backslash commands#767
fix(repl): expand :varname aliases before checking for backslash commands#767
Conversation
…ands psql allows setting aliases in ~/.psqlrc like: \set dba '\\i /path/to/start.psql' Then typing :dba at the prompt should invoke the menu. rpg was checking if the raw input starts with '\' before interpolating variables, so :dba fell through to SQL as an incomplete statement (demo-# continuation). Fix: interpolate the line first, then check the result for '\'. Applied to all three input paths: - exec_lines (file runner, e.g. \i script.psql) - run_dumb_loop (non-readline / piped stdin) - handle_line (interactive readline path) Fixes #741 test(ai): add postgres_dba integration test showing :dba alias flow
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #767 +/- ##
==========================================
- Coverage 67.35% 67.34% -0.01%
==========================================
Files 52 52
Lines 34082 34089 +7
==========================================
Hits 22954 22954
- Misses 11128 11135 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
REV — PR #767Verdict: APPROVE ✅Blocking findingsNone. Non-blocking findingsN1 — The N2 — Double interpolation in
SuggestionsS1 — In S2 — Test coverage gaps — Confidence: 7/10 The expect script validates the interactive readline path only. Not covered:
These are fine as follow-up issues — the happy-path GIF demo is solid evidence for the primary fix. SummaryCorrect fix for a real psql compatibility bug. Interpolate-before-dispatch applied consistently across all three input paths. N1 cleaned up. N2 is a pre-existing quirk, not a regression. Ready to merge. |
Sprint check — ready for mergeCI: green (latest run all checks passed) REV: APPROVE — no blocking findings. Non-blocking notes:
Evidence: No merge without Nik approval. |
Problem
psql allows setting command aliases in
~/.psqlrc:Then typing
:dbaat the prompt invokes the menu. rpg was checking if the raw input starts with\before interpolating variables — so:dbafell through to SQL and opened a continuation prompt (demo-#) instead.Fix
Interpolate the line first, then check the result for
\. Applied to all three input paths:exec_lines— file runner (\i script.psql)run_dumb_loop— non-readline / piped stdinhandle_line— interactive readline pathTest
Added
tests/ai/postgres-dba.md+tests/ai/postgres-dba.exp— expect script that:\set dba '\\i start.psql'(mirrors psqlrc setup from postgres_dba README):dba— verifies menu appears (not SQL continuation)1, presses Enter to continueq, verifies "Bye!" and clean return to rpg promptDemo:
demos/postgres-dba.gifFixes #741