I suspect a breaking change related to "include_relationships=True" and schema.load() in version 1.4.1

未关闭
#664 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@Fire162 已经在做这个了。

开始于 2026年10月6日。

  • #745 来自 @Fire162 —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python, sqlalchemy
领域
backend, databases

调研方向

首先使用 marshmallow-sqlalchemy 1.4.1 重现 UserSchema 示例,并与 1.1.0 进行比较,重点关注 include_relationships=True 且关系数据缺失时的 schema.load()。跟踪关系字段在哪个位置变为必填;完成标准是,在加载过程中可以再次省略关系字段,而不会出现缺少字段的验证错误,并且报告的行为已由回归测试覆盖。

由索引模型根据 Issue 内容生成。

描述

help wanted

Hi ! I recently had to do some testing on my local for some portion of our code that's been running happily on staging. I didn't specify a version number for my local container instance, as such it pulled 1.4.1 which is the latest. I noticed that it seems to enforce implicitly defined fields (from the include_relationships=True option), during a schema.load() which I THINK isn't the desired or USUAL behavior.

Typically (in previous versions specifically 1.1.0 ) we've been able to deserialize into objects with schemas defined with the include_relationships option set to True - without having to provide values for relationship fields (which intuitively makes sense), however for some reason it's raising a Validation (Missing field) error on 1.4.1 . This behavior wasn't reproducable on 1.1.0 (not that I would know if this is on later versions in: 1.1.0 < version < 1.4.1 because we've not used any other up until my recent local testing which used 1.4.1).

class UserSchema(Base):
    class Meta:
        model = User
        include_relationships=True  # includes for example an 'address' relationship attr (could be something like a 'backref' or explicitly declared field on the sqlalchemy model)
        include_fk = True
        load_instance = True

# usage and expected behavior
schema = UserSchema(unknown='exclude', session=session)
user = schema.load(**data)
# returns <User> object

# Observed behavior
# .. same steps
# throws 'Missing data for required 'address' field - error'
主要语言
Python
星标
580
派生
105
平均合并
9 小时 8 分钟
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

marshmallow-code/marshmallow-sqlalchemy 的其他 Issue

查看 marshmallow-code/marshmallow-sqlalchemy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。