PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks
維護者通常 1 天內回覆
評估
研究方向
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 內容生成。
描述
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 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
datajoint/datajoint-python 的其他 Issue
-
MySQL error 1143 (column-level SELECT denied) is not translated to AccessError可能已有人在做 @Bhanu73120 於 7 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 85/100
datajoint/datajoint-python#1586 · 1 則留言 ·
維護者通常 1 天內回覆
-
len() of an expression with an empty primary key generates invalid SQL可能已有人在做 @dimitri-yatsenko 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
datajoint/datajoint-python#1581 ·
維護者通常 1 天內回覆
-
dj.Diagram theme: make the font configurable可能已有人在做 @dimitri-yatsenko 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 4/5 3-5 天 新手友好度 55/100
datajoint/datajoint-python#1644 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 1-2 天 新手友好度 68/100
datajoint/datajoint-python#1641 ·
維護者通常 1 天內回覆
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 80/100
521xueweihan/HelloGitHub#4063 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"未關閉
難度 2/5 1-3 小時 新手友好度 76/100
aws-samples/sample-per-model-bedrock#409 ·
維護者通常 1 天內回覆
-
DuckDB 2.0 breaks to_pyarrow_batches可能已有人在做 @DG47 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
ibis-project/ibis#12196 ·
維護者通常 1 天內回覆