-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add versionning #50850
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
base: 7.3
Are you sure you want to change the base?
[Serializer] Add versionning #50850
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
b49f144
to
2781c01
Compare
How to deal with cases when in the future version the field should become not nullable or it's type should be changed? |
Similar PR #38478 |
Indeed, to have versioned field, due to the fact it can once be null, then by design those versionConstrained fields should be defined as nullable. I can add a check on that when reading field metadatas |
2781c01
to
0b35462
Compare
I've added a check to enforce the fact the field should be, by design, either without typehint either with a nullable type. Regarding the type change of the field, i've no clue how to enforce it. Do you have an idea? |
hello (just passing by) |
version
annotation/attribute to be set on the property holding the version of the normalized representation (only one property can be set asVersion
)VersionConstraint
annotation/attribute. That attribute control restriction on normalisation/denormalization depending on the value of the property that holdVersion
attribute. Inner properties aresince
anduntil
. At least one of them has to be set.Version.version
,VersionConstraint.since
andVersionConstraint.until
are expressed as semver string, and must be compliant with version_compare function. A property restricted by a constraint is defined as :notDefined
<since|null
<=defined
<=until|null
<notDefined
Behavior and naming are inspired by https://jmsyst.com/libs/serializer/master/reference/annotations#since and https://jmsyst.com/libs/serializer/master/reference/annotations#until
Logic is as follow:
A restricted property by a
VersionConstraint
is not added to the normalized representation if the constraint is not satisfiedA restricted property by a
VersionConstraint
is set to null if the constraint is not satisfied or to the value if the constraint is satisfiedExample of usage
I don't see any Breaking Changes up to now