Skip to content

Commit

Permalink
Fix kvesteri#238: handling hardcoded string with options.tablename at…
Browse files Browse the repository at this point in the history
…tribute via version_manager
  • Loading branch information
indiVar0508 committed Aug 15, 2022
1 parent 92eeb1e commit 9f57c38
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sqlalchemy_continuum/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
get_primary_keys,
identity,
naturally_equivalent,
get_mapper
)

from .exc import ClassNotVersioned
Expand Down Expand Up @@ -133,17 +134,19 @@ def version_table(table):
:param table: SQLAlchemy Table object
"""
table_model_class = get_mapper(table).class_ # get the table Model class name
suffixed_table_name = option(table_model_class, 'table_name') % table.name # get table_name attribute from option of version_manager
if table.schema:
return table.metadata.tables[
table.schema + '.' + table.name + '_version'
table.schema + '.' + suffixed_table_name
]
elif table.metadata.schema:
return table.metadata.tables[
table.metadata.schema + '.' + table.name + '_version'
table.metadata.schema + '.' + suffixed_table_name
]
else:
return table.metadata.tables[
table.name + '_version'
suffixed_table_name
]


Expand Down

0 comments on commit 9f57c38

Please sign in to comment.