Skip to content

create_model方法 参数obj传字典报错 #88

@SmallGarbage

Description

@SmallGarbage

(sqlalchemy>=2.0.45 sqlalchemy-crud-plus>=1.13.1)
user = await user_crud.create_model(session, {"name": "李四", "email": "[email protected]"})
按照示例文档执行如下代码报错:Error: 'dict' object has no attribute 'model_dump'
查看obj支持类型,CreateSchema = TypeVar('CreateSchema', bound=BaseModel) 应该是不支持字典吧? 还是我姿势不对=-=

另外
https://fastapi-practices.github.io/sqlalchemy-crud-plus/getting-started/quick-start/#_13完整示例代码中缺少UserUpdate类
同时然后运行报错(print(f"创建用户: {user.name}"))-->(sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions