mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
🐛 修复 PydanticType 过早加载导致获取不到子类的bug
This commit is contained in:
@@ -23,9 +23,8 @@ class PydanticType(TypeDecorator):
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
):
|
||||
for i in get_model:
|
||||
models.update(i())
|
||||
self.models = models
|
||||
self.get_model = get_model
|
||||
self._models = models
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if PYDANTIC_V2:
|
||||
@@ -56,6 +55,14 @@ class PydanticType(TypeDecorator):
|
||||
...
|
||||
raise ValueError
|
||||
|
||||
@property
|
||||
def models(self) -> tuple[type[BaseModel], ...]:
|
||||
models: set[type[BaseModel]] = set()
|
||||
for i in self.get_model:
|
||||
models.update(i())
|
||||
models.update(self._models)
|
||||
return tuple(models)
|
||||
|
||||
|
||||
class Bind(MappedAsDataclass, Model):
|
||||
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
||||
|
||||
Reference in New Issue
Block a user