Skip to content

Fixed View/Edit Data not handling generated columns properly. #9672#9761

Open
RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
RohitBhati8269:GH-9672
Open

Fixed View/Edit Data not handling generated columns properly. #9672#9761
RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
RohitBhati8269:GH-9672

Conversation

@RohitBhati8269
Copy link
Contributor

@RohitBhati8269 RohitBhati8269 commented Mar 17, 2026

Summary by CodeRabbit

  • New Features

    • Added support for PostgreSQL 12+ generated columns in the SQL editor.
  • Bug Fixes

    • Fixed row refresh to properly recalculate generated column values after INSERT and UPDATE operations.
    • Improved UPDATE statements to correctly handle conditional RETURNING clauses for refreshing row data.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 54d247fa-21b6-43ec-82a5-a40bb228adea

📥 Commits

Reviewing files that changed from the base of the PR and between 2576548 and 359942f.

📒 Files selected for processing (5)
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/12_plus/nodes.sql
  • web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx
  • web/pgadmin/tools/sqleditor/templates/sqleditor/sql/default/update.sql
  • web/pgadmin/tools/sqleditor/utils/get_column_types.py
  • web/pgadmin/tools/sqleditor/utils/save_changed_data.py

Walkthrough

These changes implement support for PostgreSQL 12+ generated columns in pgAdmin's data editor. A new SQL template retrieves column metadata including generated column indicators. The save and update logic detects generated columns, excludes them from INSERT/UPDATE operations, and conditionally refetches updated rows to recalculate generated column values.

Changes

Cohort / File(s) Summary
SQL Templates
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/12_plus/nodes.sql, web/pgadmin/tools/sqleditor/templates/sqleditor/sql/default/update.sql
New column metadata query template includes generated column detection (attgenerated = 's'). Update template now conditionally returns primary keys or OID via RETURNING clause.
Column Type Detection
web/pgadmin/tools/sqleditor/utils/get_column_types.py
Added is_generated flag to detect PostgreSQL 12+ generated columns and exclude them from INSERT/UPDATE operations.
Data Persistence & UI Update
web/pgadmin/tools/sqleditor/utils/save_changed_data.py, web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSet.jsx
INSERT operations filter out generated columns. UPDATE operations detect generated columns, collect per-row primary keys, execute separate SELECT to refetch updated rows for recalculated values. ResultSet component now handles both added and updated row refreshes.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Client as ResultSet.jsx
    participant Server as save_changed_data.py
    participant DB as PostgreSQL
    
    User->>Client: Edit row (with generated columns)
    Client->>Server: Submit changes (INSERT/UPDATE)
    
    Server->>Server: Detect generated columns
    Server->>Server: Remove generated cols from data
    
    alt INSERT Operation
        Server->>DB: INSERT (without generated cols)
        DB->>DB: Auto-calculate generated values
    else UPDATE Operation
        Server->>DB: UPDATE (without generated cols)
        DB->>DB: Auto-calculate generated values
        Server->>DB: SELECT refreshed row
        DB->>Server: Return row with recalculated values
    end
    
    Server->>Client: Return operation result + refetched data
    Client->>Client: Update UI with recalculated generated cols
    Client->>User: Display updated row
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request: fixing View/Edit Data functionality to properly handle PostgreSQL generated columns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant