Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#1,638 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@mayuriphad 已經在處理了。

開始於 2026年10月18日。

  • #1643 來自 @mayuriphad —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
75/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
postgresql, python
領域
database

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
197
分支
101
平均合併
2 天 10 小時
30 天內合併 PR
12

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

datajoint/datajoint-python 的其他 Issue

查看 datajoint/datajoint-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。