Skip to content

Commit

Permalink
修复出现的获取models的表时增加model造成的动态改变字典的错误
Browse files Browse the repository at this point in the history
Signed-off-by: tinybees <a598824322@163.com>
  • Loading branch information
tinybees committed Jul 13, 2021
1 parent c843caa commit 365723d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.md
Expand Up @@ -4,7 +4,7 @@

#### Changed
- 修复redis中注册的退出事件不进行空值的赋予

- 修复出现的获取models的表时增加model造成的动态改变字典的错误

###[1.0.11] - 2021-3-30

Expand Down
4 changes: 4 additions & 0 deletions eclients/db_client.py
Expand Up @@ -167,6 +167,10 @@ def get_engine(self, app=None, bind=None):
bind = g.bind_key if bind is None and self.is_binds and getattr(g, "bind_key", None) else bind
return super().get_engine(app=app, bind=bind)

def get_tables_for_bind(self, bind=None):
"""Returns a list of all tables relevant for a bind."""
return [table for table in list(self.Model.metadata.tables.values()) if table.info.get('bind_key') == bind]

def get_binds(self, app=None):
"""Returns a dictionary with a table->engine mapping.
Expand Down

0 comments on commit 365723d

Please sign in to comment.