Construct the switch_db context manager :param cls: the class to change the registered db :param db_alias: the name of the specific database to use
(self, cls, db_alias)
| 65 | """ |
| 66 | |
| 67 | def __init__(self, cls, db_alias): |
| 68 | """Construct the switch_db context manager |
| 69 | |
| 70 | :param cls: the class to change the registered db |
| 71 | :param db_alias: the name of the specific database to use |
| 72 | """ |
| 73 | self.cls = cls |
| 74 | self.collection = cls._get_collection() |
| 75 | self.db_alias = db_alias |
| 76 | self.ori_db_alias = cls._meta.get("db_alias", DEFAULT_CONNECTION_NAME) |
| 77 | |
| 78 | def __enter__(self): |
| 79 | """Change the db_alias and clear the cached collection.""" |
nothing calls this directly
no test coverage detected