Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow serialize_null option for Serializer #971

Merged
merged 1 commit into from
Mar 1, 2016

Conversation

michaelperrin
Copy link
Contributor

It is currently impossible to populate attributes with a null value with FOSElasticaBundle, due to to the default behavior of JMS Serializer which doesn't serialize attributes with null values.

This PR adds an option to the serializer configuration so that the JMS Serializer can be configured with the serialize_null option.

There is no specific test for this PR, as it is a configuration for JMS Serializer, and I didn't find any other test concerning its configuration (for the version and groups options). I just updated the default test configuration (with a false value, which is the default value anyway), and added an example to the documentation for better clarity.

@@ -583,6 +583,8 @@ protected function getSerializerNode()
->prototype('scalar')->end()
->end()
->scalarNode('version')->end()
->booleanNode('serialize_null')
->defaultFalse()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end() method call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was fast @stloyd, thanks!
It is fixed now.

@merk
Copy link
Member

merk commented Jan 7, 2016

Please add test coverage for this change

@michaelperrin michaelperrin force-pushed the feature/serialize_null branch 4 times, most recently from 553e6ac to a299778 Compare January 12, 2016 09:24
@michaelperrin
Copy link
Contributor Author

Hi @merk, I added the needed tests.

I make sure that null values are not serialized (and therefore not persisted) when the serialize_null option is set to false (which is the default and current behavior), and then make sure it is defined and equals to null when persisted with a true value for the option.

@michaelperrin
Copy link
Contributor Author

Hello, any news on this PR please?

@XWB XWB added this to the 3.2.0 milestone Mar 1, 2016
XWB added a commit that referenced this pull request Mar 1, 2016
Allow serialize_null option for Serializer
@XWB XWB merged commit 4fea37b into FriendsOfSymfony:master Mar 1, 2016
@XWB
Copy link
Member

XWB commented Mar 1, 2016

Thanks.

@michaelperrin
Copy link
Contributor Author

Thanks @XWB !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants