marshmallow-code / marshmallow-code/marshmallow-sqlalchemy
Don't set a field as required if it's read-only
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 580
- Forks
- 101
- Avg merge
- 7h 6m
- Merged PRs (30d)
- 3
Description
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`?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/marshmallow_sqlalchemy/convert.py line 427 and trace how nullable, default values, and dump_only determine the required flag. Confirm that dump-only fields, including the relationship case described in the issue, are not marked required; the issue is complete when the generated schema reflects that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100