Rendering a cascade or trace Diagram fails on PostgreSQL: quoted table names reach the DOT source unescaped
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- postgresql, python
調査の方向性
Start in diagram.py: _make_graph (~1309) uses full table names as node ids, _encapsulate_node_names (~1550) adds quotes, and the plain-label branch (~1756) emits label="schema"."table". Read adapter.split_full_table_name, use the unquoted schema.table for unresolved ids and labels, and keep the strip('"') lookups in make_dot (1675, 1809) consistent so schema clusters and master-part groups appear. Re-run the PostgreSQL repro; done when _repr_svg_(), save("x.svg") and save("x.png") render with nodes and edges intact.
索引モデルが issue の本文から書いたものです。
説明
Summary
On PostgreSQL, rendering a dj.Diagram whose nodes are shown by their full table names fails when any shown table inherits its whole primary key through foreign keys (a 1:1 extension, or a typical computed table, drawn without an underline). _repr_svg_(), save("x.svg") and save("x.png") raise:
AssertionError: "dot" with args ['-Tsvg', '<tmpfile>'] returned code: 1
pydot prints Graphviz's message to stdout: Error: <tmpfile>: syntax error in line N near '.'. make_dot() and make_mermaid() themselves do not raise. Diagram.cascade(...).counts() and iterating the cascade work.
Reproduced on master (f6299387) with PostgreSQL 15, pydot 4.0.1 and Graphviz 15.1.0. Every case renders on MySQL.
When it happens
- Nodes keep their full table names.
_make_graphnames each node by its class whenlookup_class_namefinds it in the diagram's context and by its full table name otherwise (diagram.py:1309).Diagram.cascadeandDiagram.traceset an empty context (diagram.py:504,589), so their nodes are always full names. ADiagrambuilt with a context that lacks the table classes does the same. - On PostgreSQL, full names are
"schema"."table"._encapsulate_node_nameswraps them in another pair of double quotes (diagram.py:1550), and pydot passes them through unescaped. - A table that adds no key attribute of its own gets a plain label (
diagram.py:1756):label="schema"."table". The bare.is the syntax error.
When no shown table has a plain label, the render succeeds but is wrong: Graphviz splits each id into several nodes ("", the schema name, ".", the table name), edges collapse, and no schema cluster is drawn.
A master-part group is not the trigger: a cascade over a master and its part where every table adds its own key attribute renders without error.
Reproduce
import datajoint as dj
# PostgreSQL connection: dj.config["database.backend"] = "postgresql", plus host, user, password
schema = dj.Schema("render_repro")
@schema
class Session(dj.Manual):
definition = """
session_id : int32
"""
class Trial(dj.Part):
definition = """
-> master
trial_id : int32
"""
@schema
class ProcessedData(dj.Manual):
definition = """
-> Session.Trial
---
value : float64
"""
Session.insert1({"session_id": 1})
Session.Trial.insert1({"session_id": 1, "trial_id": 1})
ProcessedData.insert1({"session_id": 1, "trial_id": 1, "value": 1.0})
cascade = dj.Diagram.cascade(Session & {"session_id": 1})
print(cascade.counts()) # works on both backends
cascade._repr_svg_() # MySQL: renders. PostgreSQL: AssertionError from pydot
Fix
Use a backend-neutral display name for unresolved nodes, for example the unquoted schema.table from adapter.split_full_table_name, for both the DOT node id and its label, so no raw " reaches pydot. Alternatively escape the embedded quotes in both. Keep the strip('"') lookups in make_dot (diagram.py:1675, 1809) consistent with the new ids, so schema clusters and master-part groups appear on PostgreSQL.
PostgreSQL is planned to become the default backend in 2.4, and the delete docs suggest rendering the cascade as a preview, so this should be fixed in 2.4.0.
- 主要言語
- Python
- スター
- 198
- フォーク
- 103
- 平均マージ
- 6日 1時間
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
needs-triage
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
gke-labs/kube-agents#6620 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#34719 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
cognition
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
One non-object JSON record makes the session catalog exit対応中かも @he-yufeng が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
collabnix/awesome-mcp-lists#433 ·
メンテナーはふだん 4 日以内に返信