PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks
メンテナーはふだん 4 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 75/100
調査の方向性
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
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 28
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
datajoint/datajoint-python のほかの issue
-
len() of an expression with an empty primary key generates invalid SQL対応中かも @dimitri-yatsenko が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
datajoint/datajoint-python#1581 ·
メンテナーはふだん 4 日以内に返信
-
dj.Diagram theme: make the font configurable対応中かも @dimitri-yatsenko が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
datajoint/datajoint-python#1539 · コメント 3 件 ·
メンテナーはふだん 4 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
datajoint/datajoint-python#1644 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
bug
難易度 4/5 1〜2日 初心者へのやさしさ 68/100
datajoint/datajoint-python#1641 ·
メンテナーはふだん 4 日以内に返信
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schema対応中かも @dimitri-yatsenko が 4 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 82/100
datajoint/datajoint-python#1640 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
datajoint/datajoint-python の issue をすべて見る
似ている issue
-
Validate non-divisible effective batch sizes in the Unsloth LoRA backend対応中かも @debesh-biswas が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
`rx.Model` event arguments emit `PydanticDeprecatedSince20` once per payload key対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
reflex-dev/reflex#7634 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
topoteretes/cognee#6239 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ranaroussi/yfinance#3009 ·
メンテナーはふだん 1 日以内に返信
-
Test discovery aborts on GPU builds without cuStateVec: check_cuStateVec expects a failed result but set_config() now raises RuntimeError対応中かも @dmeliksetian が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Qiskit/qiskit-aer#2495 ·
メンテナーはふだん 1 日以内に返信