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

PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks

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

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

@mayuriphad y travaille déjà.

Depuis le 18/10/2026.

  • #1643 par @mayuriphad — ouverte

Évaluation

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

Piste de recherche

Start by reading Heading.set_primary_key and the projection code that quotes renamed attributes, then reproduce the issue with the supplied dj.U example on PostgreSQL 15. Compare the generated SQL and behavior with MySQL to trace where backend quoting is lost. The change is complete when the PostgreSQL query uses backend-appropriate quoting and returns [10, 20] from to_arrays("c"), with regression coverage if the project’s test layout provides a suitable location.

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

Description

bug

Summary

On PostgreSQL, renaming an attribute in a projection of a dj.U restriction produces invalid SQL. (dj.U("b") & T).proj(c="b") compiles to SELECT DISTINCT `b` as "c" ...: the renamed attribute is quoted with MySQL backticks, which PostgreSQL rejects. MySQL returns the right rows.

The cause appears to be Heading.set_primary_key, which builds the new heading without table_info. The projection then quotes the attribute without the connection's adapter, and falls back to backticks.

Reproduction

DataJoint master, PostgreSQL 15:

import datajoint as dj

schema = dj.Schema("scratch_u_proj")


@schema
class T(dj.Manual):
    definition = """
    a : int32
    ---
    b : int32
    """


T.insert([(1, 10), (2, 10), (3, 20)])
(dj.U("b") & T).proj(c="b").to_arrays("c")
# QuerySyntaxError: syntax error at or near "as"
# LINE 1: SELECT DISTINCT `b` as "c" FROM "scratch_u_proj"."t"

On MySQL the same query returns [10, 20].

Expected behavior

The projection quotes every attribute for the connection's backend, and returns [10, 20] on PostgreSQL too.

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.