Skip to content

Fix bug in MapAdapter.build function#2261

Closed
Yourun-proger wants to merge 1 commit intopallets:mainfrom
Yourun-proger:update_func
Closed

Fix bug in MapAdapter.build function#2261
Yourun-proger wants to merge 1 commit intopallets:mainfrom
Yourun-proger:update_func

Conversation

@Yourun-proger
Copy link
Copy Markdown
Contributor

@Yourun-proger Yourun-proger commented Oct 11, 2021

Checklist:

  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@Yourun-proger
Copy link
Copy Markdown
Contributor Author

Yourun-proger commented Dec 15, 2021

I'll try to explain the meaning of my changes for maintainers to help improve it.
The whole problem is that, for example, MultiDict ({'x': 42}) inside dict.items is interpreted as {'x': [42]} !!! Especially for this case, the flattening of arrays of one element was implemented in the code. The problem was that it does not take into account the fact that the transferred object can be an ordinary dictionary, as a result of which the bug described in the issue appeared. In 1.0 version, this bug was not present, since work with MultiDict and a regular dictionary was done separately. I added to the code extra check for MultiDict to avoid strange behavior.
Any feedbacks?

@Yourun-proger Yourun-proger changed the title Updated behavior for build function in MapAdapter Fix bug in MapAdapter.build function Dec 15, 2021
@davidism
Copy link
Copy Markdown
Member

This was on the right track, but I had some more I wanted to do with it, and it needs tests as well. Continued in #2307

@davidism davidism closed this Dec 24, 2021
@Yourun-proger
Copy link
Copy Markdown
Contributor Author

Yourun-proger commented Dec 24, 2021

Hello, @davidism. I'm glad I was able to fix the bug myself correctly. Thank you for clarifying that I think correctly ("on the right track"), this means that I really began to understand something about WerkZeug !!! It is a pity that I myself cannot continue what you described (I wanted to do it tomorrow) ...

@davidism
Copy link
Copy Markdown
Member

Your commit is in the other PR, I just was doing work today.

@Yourun-proger
Copy link
Copy Markdown
Contributor Author

Yourun-proger commented Dec 24, 2021

Cool! I see the commit. Understand you)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapAdapter.build() should not flatten a value passed as single-item-list

2 participants