I suspect a breaking change related to "include_relationships=True" and schema.load() in version 1.4.1
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
调研方向
首先使用 marshmallow-sqlalchemy 1.4.1 重现 UserSchema 示例,并与 1.1.0 进行比较,重点关注 include_relationships=True 且关系数据缺失时的 schema.load()。跟踪关系字段在哪个位置变为必填;完成标准是,在加载过程中可以再次省略关系字段,而不会出现缺少字段的验证错误,并且报告的行为已由回归测试覆盖。
由索引模型根据 Issue 内容生成。
描述
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 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
marshmallow-code/marshmallow-sqlalchemy 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
-
难度 1/5 1 小时以内 新手友好度 45/100
-
Don't set a field as required if it's read-only可能已有人在做 @CyberneticX-Tech 于 64 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 25/100
marshmallow-code/marshmallow-sqlalchemy#580 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
查看 marshmallow-code/marshmallow-sqlalchemy 的全部 Issue
相似的 Issue
-
documentation good first issue priority: P2 status: ready
难度 1/5 1 小时以内 新手友好度 88/100
RhinoLink-Tech/data-fabric#500 ·
维护者通常 1 天内回复
-
backlog
难度 2/5 1-3 小时 新手友好度 78/100
EchoTools/nevr-runtime#2384 ·
维护者通常 1 天内回复
-
[Bug]: The H2 series' and the H3C's fan 3 is labelled "Chamber Fan", Bambu calls it the exhaust fan未关闭area:ui
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
btclib-org/btclib#3062 ·
维护者通常 1 天内回复
-
area:evals area:infra enhancement
难度 2/5 1-3 小时 新手友好度 74/100
jse-avl/support-bot#4 · 1 条评论 ·