Skip to content

Editing Results

Results from query execution (:TDO / :TDV) can be edited directly inside Neovim and saved back to Teradata as UPDATE statements.

This feature provides an interactive, keyboard-driven way to edit result sets without manually writing UPDATE queries while protecting against syntax or alignment corruption.

Terminal
 

Interactive Controls

When viewing query results in the split window, use the following keymaps:

Keymap Action Description
<E> Toggle Edit Mode Switches the resultset buffer between view mode and edit mode.
<CR> Edit Cell Prompts for a new value for the cell under the cursor.
<X> Set to NULL Sets the selected cell value to NULL.
<S> Save Changes Generates and executes UPDATE statements for all pending changes.
<C> Cancel Edits Discards all pending changes and restores original values.

How It Works

  1. Safe Prompt-Based Editing:
    Values are modified through an interactive Neovim prompt rather than direct buffer typing. The results buffer remains read-only and is redrawn from the data model after each change. This ensures column alignment is preserved and values containing spaces, pipes (|), or newlines are handled safely.

  2. Visual Feedback:
    Changed cells are highlighted in the grid, and a hint line displays the count of pending edits.

  3. Batched Execution:
    You can change multiple cells across multiple rows before saving. No SQL is executed against the database until you press <S>.


Editable vs. Read-Only Columns

The plugin uses Tree-sitter AST analysis to determine which columns in a result set map to actual database columns:

  • Editable Columns: Direct table column references, such as column_name, table.column_name, table.column_name AS alias, or table.column_name alias.
  • Read-Only Columns: Expressions, function calls, literals, and wildcard selects (*). These cells appear dimmed and cannot be edited.

Update Strategies

Single-Table Queries

For single-table SELECT queries, the generated WHERE clause matches every editable column against its original value ("matchall" strategy). Original NULL values are translated to IS NULL.

Affected Rows

Because updating is value-matched rather than primary-key matched, multiple identical rows may be updated. The exact number of rows changed is always reported after saving.

Join Queries

For queries with JOIN statements:

  • Edited columns are traced back to their source table using the Tree-sitter syntax tree.
  • You will be prompted to select which columns form the WHERE clause once for each table containing edits.
  • Your column selection for the WHERE clause is remembered for the duration of the buffer session.

Non-Editable Queries

Editing is disabled for complex or non-deterministic queries, including:

  • SELECT * (wildcard queries)
  • Queries using DISTINCT
  • Aggregated queries with GROUP BY or HAVING
  • Set operations (UNION, INTERSECT, EXCEPT)
  • CTEs (WITH clauses) and derived tables / subqueries
  • Multistatement execution results (:TDM / :TDMV)
  • EXPLAIN and SHOW statements