Skip to content

Fix pg_class join style and keep regression coverage#177

Merged
nettrash merged 6 commits intonettrash:v1.0.19from
iBarBuba:300-fix-pg-description-joins-with-classoid
May 1, 2026
Merged

Fix pg_class join style and keep regression coverage#177
nettrash merged 6 commits intonettrash:v1.0.19from
iBarBuba:300-fix-pg-description-joins-with-classoid

Conversation

@iBarBuba
Copy link
Copy Markdown

@iBarBuba iBarBuba commented Apr 28, 2026

What

  • Refactored sequence and index query construction into dedicated builder methods:
    • Dump::build_sequences_standalone_query in app/src/dump/core.rs
    • Table::build_indexes_bulk_query in app/src/dump/table.rs
  • Kept the pg_description joins scoped to relation comments by filtering on:
    • pg_description.classoid = 'pg_class'::regclass
    • pg_description.objsubid = 0
  • Added regression tests proving both query builders include the pg_class classoid filter:
    • build_sequences_standalone_query_filters_by_pg_class
    • build_indexes_bulk_query_filters_by_pg_class
  • Normalized SQL formatting in the new helper query strings.

Why

Existing database objects can appear in diffs when comment lookups join pg_description
without narrowing the catalog class. The fix keeps sequence and index comments tied to
pg_class entries, avoiding accidental matches from other catalogs that can reuse the
same object identifier value.

Validation

  • cargo fmt --manifest-path app/Cargo.toml
  • cargo test --manifest-path app/Cargo.toml (801 passed, 0 failed)
  • git diff --check (clean)

Links

Closes #176

Copilot AI review requested due to automatic review settings April 28, 2026 22:34
@iBarBuba iBarBuba requested a review from nettrash as a code owner April 28, 2026 22:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses false-positive diffs caused by under-constrained pg_description joins by ensuring classoid = 'pg_class'::regclass is included where pg_class-backed objects (tables, columns, indexes, sequences, views) are joined for comments. It also refactors several SQL query strings into dedicated builder functions and adds regression tests to ensure the classoid filters remain present.

Changes:

  • Add pg_description.classoid = 'pg_class'::regclass predicates to relevant comment joins (tables, table columns, indexes, sequences, views, view columns).
  • Refactor standalone/bulk dump query construction into build_*_query helper functions.
  • Add unit tests asserting the pg_class classoid filter is included in the generated queries.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/src/dump/table.rs Adds pg_class classoid filter for column/index comment joins; extracts index bulk query builder; adds regression tests.
app/src/dump/core.rs Extracts table/view/sequence query builders and adds pg_class classoid filters for object/column comment joins; adds regression tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nettrash nettrash added this to the v1.0.19 milestone May 1, 2026
@nettrash nettrash changed the base branch from master to v1.0.19 May 1, 2026 11:11
nettrash
nettrash previously approved these changes May 1, 2026
Copy link
Copy Markdown
Owner

@nettrash nettrash left a comment

Choose a reason for hiding this comment

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

Issue is real.
Fix is correct.

@nettrash
Copy link
Copy Markdown
Owner

nettrash commented May 1, 2026

@iBarBuba Please add this information to CHANGELOG. v1.0.19

@iBarBuba
Copy link
Copy Markdown
Author

iBarBuba commented May 1, 2026

@iBarBuba Please add this information to CHANGELOG. v1.0.19

@nettrash Added ✅

@nettrash nettrash merged commit 0619be5 into nettrash:v1.0.19 May 1, 2026
8 checks passed
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.

Existing tables can be falsely diffed as missing columns due to incomplete pg_description joins

3 participants