Schema Diff does not detect foreign keys that reference a different schema

Ouverte
#10,786 0 commentaires 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@dpage y travaille déjà.

Depuis le 18/11/2026.

  • #10789 par @dpage — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
57/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
postgresql, python
Domaine
databases

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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.

Langage dominant
Python
Étoiles
3.9k
Forks
922
Merge moyen
2 j 3 h
PR mergées (30 j)
33

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de pgadmin-org/pgadmin4

Toutes les issues de pgadmin-org/pgadmin4

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.