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

Đang mở
#664 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

@Fire162 đang làm issue này rồi.

Từ ngày 6/10/2026.

  • #745 của @Fire162 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python, sqlalchemy
Lĩnh vực
backend, databases

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ UserSchema với marshmallow-sqlalchemy 1.4.1 và so sánh với 1.1.0, tập trung vào schema.load() khi include_relationships=True và dữ liệu quan hệ bị thiếu. Theo dõi nơi trường quan hệ trở thành bắt buộc; được xem là hoàn thành khi các trường quan hệ có thể lại được bỏ qua trong quá trình nạp mà không phát sinh lỗi validation do thiếu trường, và hành vi được báo cáo được bao phủ bởi một regression test.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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'
Ngôn ngữ chính
Python
Star
580
Fork
105
Merge trung bình
9 giờ 8 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của marshmallow-code/marshmallow-sqlalchemy

Tất cả issue của marshmallow-code/marshmallow-sqlalchemy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.