Schema Diff does not detect foreign keys that reference a different schema
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 57/100
Research direction
Start with web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py and trace the table equality check and table_constraint_comp. Compare how referenced schemas are handled when source and target schema names differ. Done means foreign keys to same named tables in different external schemas are reported as a difference and produce DDL, while references to the compared schemas remain normalized.
Written by the indexing model from the issue text.
Description
Schema Diff reports two tables as identical when their foreign keys reference tables of the same name in different schemas, so the difference is never shown and no DDL is generated for it.
For example, comparing schemas app and app_prod where app.orders has a foreign key to common_a.users and app_prod.orders has the same foreign key to common_b.users: the tables are reported as identical.
The cause is that the table comparison's keys_to_ignore (web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py) includes references, refnsp and remote_schema, so the referenced schema is dropped from the initial equality check and table_constraint_comp is never reached. Those keys are ignored so that a reference to the compared schema itself does not count as a difference when the source and target schemas have different names; the fix is to compare the referenced schema after normalising the source and target schema names, rather than ignoring it outright.
This was found by CodeRabbit whilst reviewing #10782, which fixes a related false difference; the gap predates that PR.
- Dominant language
- Python
- Stars
- 3.9k
- Forks
- 922
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 33
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pgadmin-org/pgadmin4
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
pgadmin-org/pgadmin4#10797 ·
Maintainers usually reply within 2 days
-
Feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pgadmin-org/pgadmin4#10426 · 3 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
Bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
pgadmin-org/pgadmin4#10796 · 1 comment ·
Maintainers usually reply within 2 days
-
Bug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
pgadmin-org/pgadmin4#10783 ·
Maintainers usually reply within 2 days
-
pgAdmin 4 v9.19 - Application freezes when interacting with the UIPossibly taken @CoderKing2705 claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
pgadmin-org/pgadmin4#10767 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
All issues in pgadmin-org/pgadmin4
Similar issues
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 72/100
ida-arbeitszeit/workers-control#1588 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
aws-samples/sample-per-model-bedrock#930 ·
Maintainers usually reply within 1 day
-
Locus / Transcript lacks __bool__, so bool(transcript) queries the SQLite exon table via __len__Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Deltares/numba_celltree#100 · 1 comment ·
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
awslabs/visual-asset-management-system#1646 ·
Maintainers usually reply within 1 day