Index on a JSON path fails to declare on PostgreSQL
Los mantenedores suelen responder en 6 días
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
The index is parsed from the compiled definition by the regex in src/datajoint/declare.py around lines 616-627, which stops at the first closing parenthesis. The per-index statement is built in create_index_ddl in src/datajoint/adapters/base.py around lines 696-704. Start by reproducing the data.size:integer JSON-path index declaration on PostgreSQL and reading the generated CREATE INDEX text. Done means the table declares on both PostgreSQL and MySQL, with a test covering the JSON-path index on each backend.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug
Declaring an index on a JSON path works on MySQL but fails on PostgreSQL with a syntax error.
@schema
class Indexed(dj.Manual):
definition = """
item_id : int32
---
data = null : json
index(data.size:integer)
"""
On PostgreSQL, declaring the table fails with a syntax error in the generated statement, which starts with:
CREATE INDEX "idx_indexed_((jsonb_extract_path_text("dat" ...
Cause
PostgreSQL has no inline INDEX in CREATE TABLE, so declare() turns each index into a separate CREATE INDEX statement:
declare.pyL616–627 parses the compiled index withr"(unique\s+)?index\s*\(([^)]+)\)".[^)]+stops at the first), so a parenthesized expression is cut short. The pieces are then treated as plain column names.adapters/base.pyL696–704 (create_index_ddl) quotes each "column" as an identifier and builds the index name from the column text. For an expression, both the name and the column list end up as invalid SQL.
Suggested fix
Pass the index items to create_index_ddl as structured data (column name or expression) instead of re-parsing the MySQL-style text:
- Quote plain columns.
- Emit expressions in their own parentheses.
- Derive the index name from a sanitized or hashed form of the items, kept within PostgreSQL's 63-character limit.
A test declaring a JSON-path index on both backends would cover it.
- Lenguaje dominante
- Python
- Estrellas
- 198
- Forks
- 103
- Merge medio
- 6 d 1 h
- PR fusionados (30 d)
- 10
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
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
datajoint/datajoint-python#1703 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
datajoint/datajoint-python#1702 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
datajoint/datajoint-python#1701 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
datajoint/datajoint-python#1691 ·
Los mantenedores suelen responder en 6 días
-
dependencies needs-discussion
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
datajoint/datajoint-python#1687 ·
Los mantenedores suelen responder en 6 días
Todos los issues de datajoint/datajoint-python
Issues similares
-
needs-triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
gke-labs/kube-agents#6620 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
open-webui/open-webui#34719 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
cognition
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
One non-object JSON record makes the session catalog exitPosiblemente ocupada @he-yufeng la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
[Suggestion]: Geonode MCP ServerAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
collabnix/awesome-mcp-lists#433 ·
Los mantenedores suelen responder en 4 días