marshmallow-code / marshmallow-code/marshmallow

Reduce confusion around fields.Pluck behavior

Open
#1,315 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feedback welcome
Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

Follow-up to discussions in https://github.com/marshmallow-code/marshmallow/pull/1298#issuecomment-513354502 and https://github.com/marshmallow-code/marshmallow/issues/1311.

@deckar01 wrote:

> My confusion with the behavior of Pluck concerns me a little. Currently Pluck = flat -> nested -> flat, but it is easily confused with this use case nested -> flat -> nested. Pluck describes the operation during serialization which is similar to Function and Method, but it is really the opposite operation during deserialization. Would it make sense to provide a field that performs the opposite operation? Nest?

@sloria wrote:

> I agree that Pluck is easily misunderstood. I improved the documentation a bit in #1314. Perhaps we could improve the naming to make it more clear, as well as provide a field for the reverse operation (Nest? Deep?)

---

One possible solution might be to rename (or alias, to not break compat) `Pluck` to `Flat` and provide a `Deep` field which does the opposite (what I called `Reach` in https://github.com/marshmallow-code/marshmallow/issues/1311#issuecomment-513478342).

Feedback welcome!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the discussion in pull request 1298, issue 1311, and the documentation changes in issue 1314. Clarify whether the project wants Pluck renamed or aliased and whether a reverse-operation field should be added. Done means the API direction, compatibility expectations, and field behavior are agreed and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.