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,
|
*args: Any,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
):
|
):
|
||||||
for i in get_model:
|
self.get_model = get_model
|
||||||
models.update(i())
|
self._models = models
|
||||||
self.models = models
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
if PYDANTIC_V2:
|
if PYDANTIC_V2:
|
||||||
@@ -56,6 +55,14 @@ class PydanticType(TypeDecorator):
|
|||||||
...
|
...
|
||||||
raise ValueError
|
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):
|
class Bind(MappedAsDataclass, Model):
|
||||||
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user