Skip to content

Commit

Permalink
Add app key duplicated exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ri-gilfanov committed Apr 19, 2021
1 parent ee3b937 commit 4592eda
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions aiohttp_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ def sa_engine(engine: 'AsyncEngine', key: str = 'sa_main') -> 'Tuple[AsyncEngine


def setup(app: 'Application', engines: 'Iterable[Tuple[AsyncEngine, str]]'):
for engine, app_key in engines:
app[app_key] = engine
for engine, key in engines:
if key in app:
raise ValueError(
f'Duplicated app key `{key}`. Check `engines` argument'
f'in `aiohttp_sqlalchemy.setup()` call.')
app[key] = engine


class SAViewMixin:
Expand Down

0 comments on commit 4592eda

Please sign in to comment.