Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

schema.rebuild_lineage() fails on PostgreSQL, after emptying ~lineage

Ouverte
#1,641 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

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

Personne n'a encore pris cette issue.

Évaluation

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

Piste de recherche

Start in lineage.py at rebuild_schema_lineage and compare its information_schema queries with the adapters’ load_primary_keys_sql and load_foreign_keys_sql used by Dependencies.load. Reproduce on PostgreSQL 15 with the supplied schema and check how the function handles ~lineage when rebuilding fails. Done means lineage rebuilding works on PostgreSQL and MySQL, and a failure does not leave ~lineage empty.

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

Description

bug

Summary

schema.rebuild_lineage() fails on PostgreSQL. rebuild_schema_lineage (lineage.py) reads keys from information_schema with MySQL-only names:

  • foreign keys from KEY_COLUMN_USAGE.REFERENCED_TABLE_SCHEMA, REFERENCED_TABLE_NAME and REFERENCED_COLUMN_NAME, columns PostgreSQL does not have;
  • primary keys by CONSTRAINT_NAME = 'PRIMARY', while PostgreSQL names a primary-key constraint <table>_pkey.

The foreign-key query raises, so the rebuild stops before writing anything. It has already run DELETE FROM ~lineage by then, so the call leaves the schema with an empty ~lineage table: every join on the schema's tables is then refused, until each table is decorated again and its rows are refilled.

The docs and several messages recommend schema.rebuild_lineage() as the repair for lineage problems, and dj.migrate.rebuild_lineage calls the same function.

Reproduction

DataJoint master, PostgreSQL 15:

import datajoint as dj

schema = dj.Schema("scratch_rebuild_lineage")


@schema
class Image(dj.Manual):
    definition = """
    image_id : int32
    """


schema.rebuild_lineage()
# UnknownAttributeError: column "referenced_table_schema" does not exist
# ~lineage held 1 row before the call and 0 after it

Expected behavior

rebuild_lineage() works on both backends. It could read primary and foreign keys through the adapters' existing load_primary_keys_sql and load_foreign_keys_sql, as Dependencies.load does, and leave ~lineage unchanged if it fails.

Langage dominant
Python
Étoiles
197
Forks
101
Merge moyen
3 j 8 h
PR mergées (30 j)
28

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 datajoint/datajoint-python

Toutes les issues de datajoint/datajoint-python

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.