marshmallow-sqlalchemy icon indicating copy to clipboard operation
marshmallow-sqlalchemy copied to clipboard

Don't set a field as required if it's read-only

Open zedrdave opened this issue 7 months ago • 0 comments

This line shows that fields' required flag will only depend on whether they are nullable and have a default value:

https://github.com/marshmallow-code/marshmallow-sqlalchemy/blob/3754933b49554e6b7aa0ce282b43befb730dd7b2/src/marshmallow_sqlalchemy/convert.py#L427

But we're running into cases where certain fields (eg relations for which we want to enforce loading through the foreign key, but still want dumping the whole nested schema) are marked as required even though they are also dump_only.

Any reason for not including not dump_only as a condition for marking as required?

zedrdave avatar May 11 '25 13:05 zedrdave