PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks
Mantenedores costumam responder em até 4 dias
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 75/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 197
- Forks
- 101
- Merge médio
- 3d 8h
- PRs com merge (30d)
- 28
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de datajoint/datajoint-python
-
len() of an expression with an empty primary key generates invalid SQLTalvez já em andamento @dimitri-yatsenko assumiu há 5 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
datajoint/datajoint-python#1581 ·
Mantenedores costumam responder em até 4 dias
-
dj.Diagram theme: make the font configurableTalvez já em andamento @dimitri-yatsenko assumiu há 5 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
datajoint/datajoint-python#1539 · 3 comentários ·
Mantenedores costumam responder em até 4 dias
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
datajoint/datajoint-python#1644 · 1 comentário ·
Mantenedores costumam responder em até 4 dias
-
bug
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 68/100
datajoint/datajoint-python#1641 ·
Mantenedores costumam responder em até 4 dias
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schemaTalvez já em andamento @dimitri-yatsenko assumiu há 5 dias. Abertabug
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 82/100
datajoint/datajoint-python#1640 · 1 comentário ·
Mantenedores costumam responder em até 4 dias
Todas as issues de datajoint/datajoint-python
Issues semelhantes
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
sergey-miryanov/gcmon#230 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
Mantenedores costumam responder em até 1 dia
-
[BUG] Failed archive extraction deletes the dataset cacheTalvez já em andamento @dajiaohuang assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
alibaba/GraphScope#4674 ·