feat: Query parameters in interactive mode (:param)#98
Open
Ignition wants to merge 2 commits into
Open
Conversation
Add cypher-shell-style query parameters to the interactive REPL: :param <name> <expression> set a parameter to a server-evaluated value :params list all set parameters :params clear remove all parameters Expressions are evaluated server-side via RETURN, giving full Cypher type support, and may reference previously set parameters. Set parameters are passed to every subsequent query via mg_session_run. The parser (ParseParamCommand) and parameter store (ParamStore) live in a new mgclient-only `params` library and are covered by unit tests. mg_memory is extracted into its own header so the library and its test don't depend on replxx. The REPL wiring (dispatch, server-eval, ExecuteQuery params arg) is thin glue verified manually.
05291fb to
2662b16
Compare
mgconsole assembles multi-line queries itself via the continuation prompt and does not use replxx's in-buffer multiline editing, which is buggy in the pinned release-0.0.4. history_previous() calls prev_newline_position(_pos - 1) without the `_pos > 0` guard its sibling history_next() has; with a newline at buffer position 0 (navigating up through a recalled multi-line history entry) it passes -1 and trips an assertion that aborts the process. Separately, in-buffer multiline redraws clear to end of screen and erase already-printed output. Patch replxx (replxx-patches/, applied via the replxx-proj PATCH_COMMAND) to add the missing bounds guard to history_previous. This fixes the abort for any newline-bearing buffer, including multi-line entries decoded from the history file. Rebind Ctrl-J (line feed, 0x0A) to commit_line so a bare newline submits the current line like Enter instead of feeding replxx's NEW_LINE action. A multi-line paste then submits one physical line at a time, which is what GetQuery expects, and keeps pasted or typed newlines out of the buffer so the redraw corruption stays unreachable for the common paste case. It does not cover newlines that arrive from history, which is why the bounds guard is the actual crash fix.
2662b16 to
79b81af
Compare
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.
Query parameters
Adds cypher-shell-style parameters to the interactive REPL:
:param <name> <expression>— set a parameter to a server-evaluated value:params— list parameters:params clear— remove allExpressions are evaluated server-side via
RETURN, so parameters get full Cypher types and can reference earlier ones (:param age 21 * 2). Set values are passed to every later query and used as$name.Fix: replxx abort on multi-line buffers
history_previous()in the pinned replxx indexesprev_newline_position(_pos - 1)without the_pos > 0guard its sibling has, so navigating up through a multi-line buffer aborts the shell. Fixed by a small patch to replxx applied viaPATCH_COMMAND, plus a Ctrl-J rebind so pasted multi-line input submits one line at a time.