Skip to content

Conversation

@Hanmac
Copy link
Contributor

@Hanmac Hanmac commented Oct 6, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #58056
License MIT

It still does work when the Normalizer is used with Serializer (like it normally would?),

@carsonbot

This comment was marked as outdated.

@Hanmac Hanmac marked this pull request as ready for review October 6, 2024 19:43
@Hanmac Hanmac requested a review from dunglas as a code owner October 6, 2024 19:43
@carsonbot carsonbot added this to the 6.4 milestone Oct 6, 2024
@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.4" but it seems your PR description refers to branch "7.2 for features / 5.4, 6.4, and 7.1 for bug fixes".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbot
Copy link

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 6, 2024

"Allow edits from maintainer" doesn't work because that is a Group Repository

@OskarStark OskarStark changed the title Add ScalarNormalizer to allow custom values for boolean Add ScalarNormalizer to allow custom values for boolean Oct 8, 2024
@carsonbot carsonbot changed the title Add ScalarNormalizer to allow custom values for boolean [Serializer] Add ScalarNormalizer to allow custom values for boolean Oct 8, 2024
@andreybotanic
Copy link

Your fix is very specific. Why ScalarNormalizer allows only booleans? You probably should create BooleanNormalizer instead. And it also mast supports denormalization, so you have to add appropriate methods and fix demormalization method in AbstractObjectNormalizer

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 9, 2024

@andreybotanic because this is only the start, for #58429 I wanted to add something to format numeric/float/int too,
but I first need to think what the best way would be. Probably "sprintf" Format Strings?

Yeah, denormalization might need to be done too. My use-case was for normalizing into stuff that can be denormalized too. (like "true/false" for boolean.)

I will try to update the denormalize way soon. (for example, "yes/no" for boolean)

@Hanmac
Copy link
Contributor Author

Hanmac commented Jan 29, 2025

@nicolas-grekas similar to #59501 can you look into this MR?

I need to find a way to normalize boolean into "true" and "false" instead of "1" and "0"

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 2, 2025

hm, I need to think about the test cases.

For example: testChildContextKeepsOriginalContextCacheKey
thanks to the change, it creates a new child-context for the scalar attributes

@Hanmac Hanmac changed the title [Serializer] Add ScalarNormalizer to allow custom values for boolean [Serializer] Fix AbstractObjectNormalizer to allow scalar values to be normalized Oct 2, 2025
@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 17, 2025

Finally, the tests are green again 😂

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 30, 2025

for reference, @stof said this in Slack:

looking at a git blame, I suspect that this was working between 2.7 (when serializer added support for normalizing scalars) and 6.1, and got broken in 6.2 (when the handling of scalars was changed in AbstractObjectNormalizer to fix an issue in #49525)

@nicolas-grekas
Copy link
Member

Thank you @Hanmac.

nicolas-grekas added a commit that referenced this pull request Nov 12, 2025
…r values to be normalized (Hanmac, xabbuh)

This PR was merged into the 6.4 branch.

Discussion
----------

[Serializer] Fix `AbstractObjectNormalizer` to allow scalar values to be normalized

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |  Fix #58056
| License       | MIT

It still does work when the Normalizer is used with Serializer (like it normally would?),

Commits
-------

e195833 ObjectNormalizer: allow null and scalar
@nicolas-grekas
Copy link
Member

Merged as c5a661a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Serializer] Allow AbstractObjectNormalizer to normalize Scalar values too

7 participants