Skip to content

Fix the Statistics node failing to list its children in Object Explorer. #10310 - #10639

Open
kundansable wants to merge 3 commits into
pgadmin-org:masterfrom
kundansable:fix-10310-statistics-nodes-sql
Open

kundansable wants to merge 3 commits into
pgadmin-org:masterfrom
kundansable:fix-10310-statistics-nodes-sql

Conversation

@kundansable

@kundansable kundansable commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

pgAdmin renders its templates with trim_blocks, which removes the newline after a block tag. nodes.sql ended its WHERE clause with a conditional, so with neither a statistics id nor schema_diff set, which is what expanding the Statistics collection sends, the SQL ran into "::oidORDER BY" and the server rejected it.

Give each condition its own line ending in plain text, and add a test that renders the template for every parameter combination and runs it.

Summary by CodeRabbit

  • Bug Fixes

    • Improved schema filtering in statistics queries, ensuring consistent results when a schema filter is provided.
    • Prevented malformed SQL when optional query conditions are rendered, improving reliability with PostgreSQL 14 and newer.
  • Tests

    • Added integration coverage for statistics queries, including filter combinations, SQL formatting, and successful execution against PostgreSQL.

…er. pgadmin-org#10310

pgAdmin renders its templates with trim_blocks, which removes the newline
after a block tag. nodes.sql ended its WHERE clause with a conditional, so
with neither a statistics id nor schema_diff set, which is what expanding
the Statistics collection sends, the SQL ran into "::oidORDER BY" and the
server rejected it.

Give each condition its own line ending in plain text, and add a test that
renders the template for every parameter combination and runs it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pgadmin-org/pgadmin4/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee98d13e-8b4a-4237-9dbd-bb7499b8460a
📥 Commits

Reviewing files that changed from the base of the PR and between c08c82f and ee04832.

📒 Files selected for processing: 1
  • web/pgadmin/browser/server_groups/servers/databases/schemas/statistics/tests/test_statistics_nodes_template.py
🚧 Files skipped from review as they are similar to previous changes: 1
  • web/pgadmin/browser/server_groups/servers/databases/schemas/statistics/tests/test_statistics_nodes_template.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The statistics SQL template now separates its base WHERE clause from conditional schema filtering. New tests render and execute the template for four scenarios on PostgreSQL 14 and later.

Changes

Statistics query filtering

Layer / File(s) Summary
Query filtering and validation
web/pgadmin/browser/server_groups/servers/databases/schemas/statistics/templates/statistics/sql/default/nodes.sql, web/pgadmin/browser/server_groups/servers/databases/schemas/statistics/tests/test_statistics_nodes_template.py
The template uses WHERE true and adds the schema OID predicate when scid is set. Tests render SQL for four scenarios, check expected clauses and keyword spacing, and execute the SQL against the server.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: hiteshjambhale

Merge Risk: ⚪ Minimal · up to ee048

The reported Statistics node SQL failure is covered by the new test. No outstanding issue is identified before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: fixing the Statistics node so it lists its children in Object Explorer. This matches the PR objective and template fix.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@hiteshjambhale hiteshjambhale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. Looks good to me. Please fix the pycodestyle and merge.

kundansable and others added 2 commits October 21, 2026 15:28
…g#10310

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…g#10310

The previous commit accidentally reverted the template change along with
the line-length fix. Put it back.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants