Skip to content

Commit df908b7

Browse files
refactor: use adapter.split_full_table_name() in FreeTable and add_parts
Replace two more ad-hoc name-splitting implementations: - FreeTable.__init__: was s.strip('`"') for s in name.split(".") - Diagram.add_parts.is_part: same pattern Both now use the canonical adapter.split_full_table_name(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3d5561e commit df908b7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/datajoint/diagram.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,12 @@ def add_parts(self) -> "Diagram":
208208
New diagram with part tables included.
209209
"""
210210

211+
split = self._connection.adapter.split_full_table_name
212+
211213
def is_part(part, master):
212-
part = [s.strip('`"') for s in part.split(".")]
213-
master = [s.strip('`"') for s in master.split(".")]
214-
return master[0] == part[0] and master[1] + "__" == part[1][: len(master[1]) + 2]
214+
p_schema, p_table = split(part)
215+
m_schema, m_table = split(master)
216+
return m_schema == p_schema and m_table + "__" == p_table[: len(m_table) + 2]
215217

216218
self = Diagram(self) # copy
217219
self.nodes_to_show.update(n for n in self.nodes() if any(is_part(n, m) for m in self.nodes_to_show))

src/datajoint/table.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,8 +1559,7 @@ class FreeTable(Table):
15591559
"""
15601560

15611561
def __init__(self, conn, full_table_name):
1562-
# Backend-agnostic quote stripping (MySQL uses `, PostgreSQL uses ")
1563-
self.database, self._table_name = (s.strip('`"') for s in full_table_name.split("."))
1562+
self.database, self._table_name = conn.adapter.split_full_table_name(full_table_name)
15641563
self._connection = conn
15651564
self._support = [full_table_name]
15661565
self._heading = Heading(

0 commit comments

Comments
 (0)