Index on a JSON path fails to declare on PostgreSQL
维护者通常 6 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 55/100
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 198
- 派生
- 103
- 平均合并
- 6 天 1 小时
- 30 天内合并 PR
- 10
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
datajoint/datajoint-python 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1703 ·
维护者通常 6 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1702 ·
维护者通常 6 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1701 ·
维护者通常 6 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
datajoint/datajoint-python#1691 ·
维护者通常 6 天内回复
-
dependencies needs-discussion
难度 2/5 1-3 小时 新手友好度 68/100
datajoint/datajoint-python#1687 ·
维护者通常 6 天内回复
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
cognition
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 78/100
collabnix/awesome-mcp-lists#433 ·
维护者通常 4 天内回复
-
CrossEntropyFilter raises on zero probabilities and single-class results可能已有人在做 @NopeCharon 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
Archmonger/ServeStatic#129 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复