PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 75/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 197
- Forks
- 101
- Merge medio
- 3 d 8 h
- PR fusionados (30 d)
- 28
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de datajoint/datajoint-python
-
len() of an expression with an empty primary key generates invalid SQLPosiblemente ocupada @dimitri-yatsenko la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
datajoint/datajoint-python#1581 ·
Los mantenedores suelen responder en 4 días
-
dj.Diagram theme: make the font configurablePosiblemente ocupada @dimitri-yatsenko la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
datajoint/datajoint-python#1539 · 3 comentarios ·
Los mantenedores suelen responder en 4 días
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
datajoint/datajoint-python#1644 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
bug
Dificultad 4/5 1-2 días Aptitud para principiantes 68/100
datajoint/datajoint-python#1641 ·
Los mantenedores suelen responder en 4 días
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schemaPosiblemente ocupada @dimitri-yatsenko la tomó hace 4 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 82/100
datajoint/datajoint-python#1640 · 1 comentario ·
Los mantenedores suelen responder en 4 días
Todos los issues de datajoint/datajoint-python
Issues similares
-
comp/tools P2 type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#142908 · 1 comentario ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pagesPosiblemente ocupada @github-actions la tomó hoy. Abiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlinePosiblemente ocupada @r2jaff la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ComposioHQ/composio#5054 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pytorch/tensordict#3286 ·
Los mantenedores suelen responder en 1 día