Skip to content
Snippets Groups Projects
Commit 5e9369d9 authored by Leah Tacke genannt Unterberg's avatar Leah Tacke genannt Unterberg
Browse files

maybe fixed git submodule for forked dependency

parent dfb406d3
No related branches found
No related tags found
No related merge requests found
......@@ -20,14 +20,14 @@ if TYPE_CHECKING:
def check_all_compound_same_parent(fk: sa.ForeignKey):
"""Checks if all other ForeignKey Constraints of our table are on the same parent table as the current one."""
table = fk.column.table.fullname
table = get_sa_table_name(fk.column.table)
if not fk.constraint:
return True
for col in fk.constraint.table.columns:
if not col.foreign_keys:
return False
for foreign_column in col.foreign_keys:
if table != foreign_column.column.table.fullname:
if table != get_sa_table_name(foreign_column.column.table):
return False
return True
......@@ -47,9 +47,9 @@ def relation_to_intermediary(fk: sa.ForeignKey) -> Relation:
# if this is the case, we are not optional and must be unique
right_cardinality = "1" if check_all_compound_same_parent(fk) else "*"
return Relation(
right_table=format_name(fk.parent.table.fullname),
right_table=format_name(get_sa_table_name(fk.parent.table)),
right_column=format_name(fk.parent.name),
left_table=format_name(fk.column.table.fullname),
left_table=format_name(get_sa_table_name(fk.column.table)),
left_column=format_name(fk.column.name),
right_cardinality=right_cardinality,
left_cardinality="?" if fk.parent.nullable else "1",
......@@ -81,12 +81,15 @@ def column_to_intermediary(
is_null=col.nullable,
)
def get_sa_table_name(t: sa.Table) -> str:
return (t.schema + '.' + t.name) if t.schema else t.name
def table_to_intermediary(table: sa.Table) -> Table:
"""Transform an SQLAlchemy Table object to its intermediary representation."""
table_columns = getattr(table.c, "_colset", getattr(table.c, "_data", {}).values())
return Table(
name=table.fullname,
name=get_sa_table_name(table),
columns=[column_to_intermediary(col) for col in table_columns],
)
......
......@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "eralchemy"
version = "1.5.0"
version = "1.5.1"
description = "Simple entity relation (ER) diagrams generation"
authors = [
{ name = "Alexis Benoist", email = "Alexis-benoist@users.noreply.github.com"},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment