最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Inheriting from SQLModel with table=True raises Value error if parent has a non-trivial field type - Stack Overflow

programmeradmin1浏览0评论

On sqlmodel 0.0.22, the following code will crash with ValueError: <class 'list'> has no matching SQLAlchemy type

from sqlalchemy import ARRAY
from sqlmodel import Field, SQLModel, String


class Foo(SQLModel, table=True):
    id: str = Field(primary_key=True)
    bar: list[str] = Field(sa_type=ARRAY(String))


class Bar(Foo):
    pass

Removing table=True gets rid of the error.

Does anyone know why and is there a workaround?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论