fix: exclude non-editable/alias columns from Query Tool row UPDATE#10171
fix: exclude non-editable/alias columns from Query Tool row UPDATE#10171kundansable wants to merge 1 commit into
Conversation
The added (INSERT) branch of save_changed_data() already filtered out columns that aren't backed by a real table column (added for pgadmin-org#9939 / pgadmin-org#10015), but the updated (UPDATE) branch did not. Editing a row that includes an aliased/expression column (e.g. first_name || ' ' || last_name AS the_name) sent that alias into the generated UPDATE's SET clause, which fails with "column ... does not exist" even though the grid already marks the column read-only. Apply the same editable-columns guard to the updated branch, and skip the row entirely if nothing editable remains after filtering. Fixes pgadmin-org#10103
WalkthroughThe updated save path filters row data to editable table columns before generating UPDATE statements and skips rows containing no editable fields. ChangesUpdate filtering
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/pgadmin/tools/sqleditor/utils/save_changed_data.py (1)
180-194: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for updated rows with read-only aliases.
Please add or verify tests covering:
- an updated row containing both an editable column and an alias/computed column;
- a row containing only a non-editable alias.
Assert that the editable value is persisted and the alias-only row produces no
UPDATE.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/pgadmin/tools/sqleditor/utils/save_changed_data.py` around lines 180 - 194, Extend the regression tests covering the save-changed-data flow around the data filtering logic to include a row with both an editable column and a non-editable alias, asserting the editable value is persisted, and a row containing only the alias, asserting no UPDATE is generated or executed. Reuse the existing test fixtures and assertions for updated rows and SQL persistence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@web/pgadmin/tools/sqleditor/utils/save_changed_data.py`:
- Around line 180-194: Extend the regression tests covering the
save-changed-data flow around the data filtering logic to include a row with
both an editable column and a non-editable alias, asserting the editable value
is persisted, and a row containing only the alias, asserting no UPDATE is
generated or executed. Reuse the existing test fixtures and assertions for
updated rows and SQL persistence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d701b2fa-7918-4e34-9c15-30690aac3d3f
📒 Files selected for processing (1)
web/pgadmin/tools/sqleditor/utils/save_changed_data.py
Summary
Fixes #10103 — editing a row in the Query Tool result grid fails to save with
column "..." does not existwhen the query includes an aliased/computed column (e.g.first_name || ' ' || last_name AS the_name), even though that column is already shown as read-only (lock icon) in the grid.Root Cause
save_changed_data()has two code paths —added(INSERT) andupdated(UPDATE). Theaddedpath already filters the outgoing payload down to real, editable table columns (fixed for #9939 in #10015), using the samecolumns_info[...]['is_editable']metadata that drives the grid's lock icon. Theupdatedpath never got the equivalent filter, so an edited row that includes an alias/expression column sends that alias straight into the generatedUPDATE ... SETclause — and Postgres rejects it because there's no such real column.Fix
Apply the same editable-columns guard to the
updatedbranch: drop any key from the changed-row payload that isn't a real, editable table column, and skip the row entirely if nothing editable remains after filtering (avoiding an empty/invalidSETclause).Test Steps
first_namefromJohntoJaneon the existing row.first_nameis updated. Nocolumn "the_name" ... does not existerror.Summary by CodeRabbit