PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 75/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 197
- Fork
- 101
- Merge medio
- 2g 10h
- PR unite (30g)
- 12
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di datajoint/datajoint-python
-
MySQL error 1143 (column-level SELECT denied) is not translated to AccessErrorForse già presa @Bhanu73120 l’ha presa 7 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
datajoint/datajoint-python#1586 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
len() of an expression with an empty primary key generates invalid SQLForse già presa @dimitri-yatsenko l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
datajoint/datajoint-python#1581 ·
I maintainer di solito rispondono entro 1 giorno
-
dj.Diagram theme: make the font configurableForse già presa @dimitri-yatsenko l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
datajoint/datajoint-python#1539 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
datajoint/datajoint-python#1644 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 68/100
datajoint/datajoint-python#1641 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di datajoint/datajoint-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
anchore/grype-db#1149 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sitesForse già presa @HootRock l’ha presa oggi. Apertacomp/cli P2 type/perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NousResearch/hermes-agent#142417 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
SMC SPEC
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
tenstorrent/tt-oca-harness#3287 ·
I maintainer di solito rispondono entro 1 giorno
-
bug enhancement python
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
I maintainer di solito rispondono entro 1 giorno
-
Critical advisories on mainApertasecurity
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fabriziosalmi/wildbox#801 ·
I maintainer di solito rispondono entro 1 giorno