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

Make property mapping fail when record is missing field, unless the property is marked with an attribute #796

Conversation

RichardIrons-neo4j
Copy link
Contributor

This changes the behaviour of property mapping so that if a property is in the class but it cannot be populated, an exception is thrown, instead of it silently doing nothing. Two new attributes have been added:

  • [MappingOptional] (properties only)
    This marks the property as optional. If a value is not found in the record, the mapper does nothing (the old default behaviour).
  • [MappingDefaultValue(someValue)] (properties and constructor parameters)
    This provides a default value which will be put into the property or constructor if a suitable value is not found in the record.

Tests were added for the new features, as well as the specific issues raised that led to this change.

…attributes for making things optional or giving them a default value
Copy link
Contributor

@AndyHeap-NeoTech AndyHeap-NeoTech left a comment

Choose a reason for hiding this comment

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

I like what I see.

@RichardIrons-neo4j RichardIrons-neo4j merged commit 69a4de2 into neo4j:5.0 May 1, 2024
5 checks passed
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.

3 participants