Skip to content

Commit 3d5561e

Browse files
refactor: use adapter.split_full_table_name() instead of local helper
Remove _split_full_name() from diagram.py and use the canonical adapter.split_full_table_name() method throughout. All call sites are instance methods with access to self._connection.adapter. Eliminates duplicate name-parsing logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 609daeb commit 3d5561e

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/datajoint/diagram.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@
4747
logger = logging.getLogger(__name__.split(".")[0])
4848

4949

50-
def _split_full_name(full_name: str) -> tuple[str, str]:
51-
"""Split a quoted full table name into (schema, table) regardless of quote style."""
52-
parts = full_name.strip('`"').split("`.`") if "`" in full_name else full_name.strip('"').split('"."')
53-
if len(parts) == 2:
54-
return parts[0], parts[1]
55-
# Fallback: strip all quotes and split on dot
56-
stripped = full_name.replace("`", "").replace('"', "")
57-
schema, _, table = stripped.partition(".")
58-
return schema, table
59-
60-
6150
class Diagram(nx.DiGraph): # noqa: C901
6251
"""
6352
Schema diagram as a directed acyclic graph (DAG).
@@ -782,7 +771,7 @@ def _apply_collapse(self, graph: nx.DiGraph) -> tuple[nx.DiGraph, dict[str, str]
782771
for class_name in nodes_to_collapse:
783772
full_name = class_to_full.get(class_name)
784773
if full_name:
785-
schema_name, _ = _split_full_name(full_name)
774+
schema_name, _ = self._connection.adapter.split_full_table_name(full_name)
786775
if schema_name:
787776
if schema_name not in collapsed_by_schema:
788777
collapsed_by_schema[schema_name] = []
@@ -806,7 +795,7 @@ def _apply_collapse(self, graph: nx.DiGraph) -> tuple[nx.DiGraph, dict[str, str]
806795
for node in graph.nodes():
807796
full_name = class_to_full.get(node)
808797
if full_name:
809-
db_schema, _ = _split_full_name(full_name)
798+
db_schema, _ = self._connection.adapter.split_full_table_name(full_name)
810799
if db_schema:
811800
cls = self._resolve_class(node)
812801
if cls is not None and hasattr(cls, "__module__"):
@@ -850,7 +839,7 @@ def _apply_collapse(self, graph: nx.DiGraph) -> tuple[nx.DiGraph, dict[str, str]
850839
for node in graph.nodes():
851840
full_name = class_to_full.get(node)
852841
if full_name:
853-
schema_name, _ = _split_full_name(full_name)
842+
schema_name, _ = self._connection.adapter.split_full_table_name(full_name)
854843
if schema_name and node in nodes_to_collapse:
855844
node_mapping[node] = collapsed_labels[schema_name]
856845
else:
@@ -864,7 +853,7 @@ def _apply_collapse(self, graph: nx.DiGraph) -> tuple[nx.DiGraph, dict[str, str]
864853
neighbor = next(iter(neighbors))
865854
full_name = class_to_full.get(neighbor)
866855
if full_name:
867-
schema_name, _ = _split_full_name(full_name)
856+
schema_name, _ = self._connection.adapter.split_full_table_name(full_name)
868857
if schema_name:
869858
node_mapping[node] = collapsed_labels[schema_name]
870859
continue
@@ -990,7 +979,7 @@ def make_dot(self):
990979
schema_modules = {} # schema_name -> set of module names
991980

992981
for full_name in self.nodes_to_show:
993-
schema_name, _ = _split_full_name(full_name)
982+
schema_name, _ = self._connection.adapter.split_full_table_name(full_name)
994983
if schema_name:
995984
class_name = lookup_class_name(full_name, self.context) or full_name
996985
schema_map[class_name] = schema_name
@@ -1255,7 +1244,7 @@ def make_mermaid(self) -> str:
12551244
schema_modules = {} # schema_name -> set of module names
12561245

12571246
for full_name in self.nodes_to_show:
1258-
schema_name, _ = _split_full_name(full_name)
1247+
schema_name, _ = self._connection.adapter.split_full_table_name(full_name)
12591248
if schema_name:
12601249
class_name = lookup_class_name(full_name, self.context) or full_name
12611250
schema_map[class_name] = schema_name

0 commit comments

Comments
 (0)