Skip to content

Commit

Permalink
sql: Use replacement for deprecated mapped_table property
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed Feb 19, 2020
1 parent 9328664 commit 17c5558
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions idiosync/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(cls, name, bases, dct):
super().__init__(name, bases, dct)
# Construct a namespace based on the table name if applicable
if cls.model is not None:
table = inspect(cls.model.orm).mapped_table
table = inspect(cls.model.orm).persist_selectable
cls.uuid_ns = uuid.uuid5(NAMESPACE_SQL, table.name)


Expand Down Expand Up @@ -440,7 +440,7 @@ def alembic(self):

def prepare_table(self, orm):
"""Prepare table for use as part of an idiosync user database"""
table = inspect(orm).mapped_table
table = inspect(orm).persist_selectable
if table.name not in inspect(self.engine).get_table_names():
op = alembic.operations.ops.CreateTableOp.from_table(table)
self.alembic.invoke(op)
Expand All @@ -451,7 +451,7 @@ def prepare_column(self, column):
# disassociated from the table, to work around an apparent bug
# in alembic (or sqlalchemy) that would otherwise result in an
# error "Column object 'c' already assigned to Table 't'".
table = column.parent.mapped_table.tometadata(MetaData())
table = column.parent.persist_selectable.tometadata(MetaData())
column = table.columns[column.name]
columns = inspect(self.engine).get_columns(table.name)
if not any(x['name'] == column.name for x in columns):
Expand Down

0 comments on commit 17c5558

Please sign in to comment.