PostgreSQL: describe() drops [unique] foreign keys and secondary indexes, and alter() fails on tables that have them
Mantenedores costumam responder em até 6 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 73/100
Direção de pesquisa
Start with src/datajoint/adapters/postgres.py around get_indexes_sql and src/datajoint/heading.py around the code that reads index columns. Check the PostgreSQL adapter tests for coverage of heading.indexes, describe(), and unchanged alter() calls; add or update cases for regular, unique, and primary key indexes. Done when PostgreSQL reports the same secondary index and unique foreign key metadata as MySQL and an unchanged definition alters without error.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
On PostgreSQL, heading.indexes is always empty. As a result, describe() loses [unique] foreign keys and secondary indexes, and alter() fails on any table that has a secondary index.
get_indexes_sql returns indexname, indexdef from pg_indexes (adapters/postgres.py#L1025-L1030). The heading reads index_name, column_name, seq_in_index and non_unique (heading.py#L625-L649), so it finds none of them.
Repro (master, eefe74b4)
@schema
class Parent(dj.Manual):
definition = """
parent_id : int32
"""
@schema
class Other(dj.Manual):
definition = """
other_id : int32
"""
@schema
class Child(dj.Manual):
definition = """
child_id : int32
---
-> [unique] Parent
-> Other
a : int32
b : varchar(32)
c : int32
index(a)
unique index(b, c)
"""
| MySQL | PostgreSQL | |
|---|---|---|
Child().heading.indexes |
('a',), ('b', 'c') unique, ('other_id',), ('parent_id',) unique |
{} |
Child().describe() |
-> [unique] Parent, INDEX (a), UNIQUE INDEX (b, c) |
-> Parent, no index lines |
Child.alter(prompt=False) with the definition unchanged |
no change | NotImplementedError: table.alter cannot alter indexes (yet) |
The indexes exist and are enforced on both backends; a duplicate parent_id is rejected on both. Only reading them back fails.
Expected
The same heading.indexes and describe() output as on MySQL, and alter() with an unchanged definition changing nothing.
Suggested fix
Query pg_index and pg_attribute for index_name, column_name, non_unique and seq_in_index, and leave out the primary-key index (indisprimary).
Related: #1672, about declaring indexes on JSON paths on PostgreSQL.
- Linguagem predominante
- Python
- Estrelas
- 198
- Forks
- 103
- Merge médio
- 6d 1h
- PRs com merge (30d)
- 10
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
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
datajoint/datajoint-python#1703 ·
Mantenedores costumam responder em até 6 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
datajoint/datajoint-python#1702 ·
Mantenedores costumam responder em até 6 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
datajoint/datajoint-python#1701 ·
Mantenedores costumam responder em até 6 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
datajoint/datajoint-python#1691 ·
Mantenedores costumam responder em até 6 dias
-
dependencies needs-discussion
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
datajoint/datajoint-python#1687 ·
Mantenedores costumam responder em até 6 dias
Todas as issues de datajoint/datajoint-python
Issues semelhantes
-
needs-triage
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 85/100
gke-labs/kube-agents#6620 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
open-webui/open-webui#34719 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
cognition
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
One non-object JSON record makes the session catalog exitTalvez já em andamento @he-yufeng assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
collabnix/awesome-mcp-lists#433 ·
Mantenedores costumam responder em até 4 dias