Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
micoli wants to merge2 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
frommicoli:add-versionning-to-serializer

Conversation

micoli
Copy link

@micolimicoli commentedJul 2, 2023
edited by OskarStark
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#30848
LicenseMIT
Doc PRsymfony/symfony-docs#...
  • Addversion annotation/attribute to be set on the property holding the version of the normalized representation (only one property can be set asVersion)
  • AddVersionConstraint 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.
  • EitherVersion.version,VersionConstraint.since andVersionConstraint.until are expressed as semver string, and must be compliant withversion_compare function. A property restricted by a constraint is defined as :notDefined <since|null <=defined <=until|null <notDefined

Behavior and naming are inspired byhttps://jmsyst.com/libs/serializer/master/reference/annotations#since andhttps://jmsyst.com/libs/serializer/master/reference/annotations#until

Logic is as follow:

  • Normalization
    A restricted property by aVersionConstraint is not added to the normalized representation if the constraint is not satisfied
  • Denormalization
    A restricted property by aVersionConstraint is set to null if the constraint is not satisfied or to the value if the constraint is satisfied

Example of usage

class VersionAwareObject{private$foo;/**     * @Version     */publicstring$version;/**     * @VersionConstraint(     *     since="1.1",     *     until="1.5"     * )     */public ?string$name;/**     * @VersionConstraint(     *     since="1.6"     * )     */public ?string$lastName;}

I don't see any Breaking Changes up to now

BenMorel and ScullWM reacted with thumbs up emojiKoc reacted with rocket emoji
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.4 branch.

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!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@micolimicoliforce-pushed theadd-versionning-to-serializer branch 2 times, most recently fromb49f144 to2781c01CompareJuly 2, 2023 17:03
@antonkomarev
Copy link

How to deal with cases when in the future version the field should become not nullable or it's type should be changed?

@asispts
Copy link
Contributor

Similar PR#38478

@micoli
Copy link
Author

Similar PR#38478

I'v only seen#35617, not this one. Hence this PR and mine have the same purpose, I can close mine if it's desired

@micoli
Copy link
Author

How to deal with cases when in the future version the field should become not nullable or it's type should be changed?

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

@micolimicoliforce-pushed theadd-versionning-to-serializer branch from2781c01 to0b35462CompareJuly 2, 2023 18:47
@micoli
Copy link
Author

How to deal with cases when in the future version the field should become not nullable or it's type should be changed?

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?

@OskarStarkOskarStark changed the titleAdd versionning to serializer[Serializer] Add versionningJul 3, 2023
@94noni
Copy link
Contributor

hello (just passing by)
is it relevant to add annotation as the PR target v6 withphp v8.1 as minimal requirement?
perhaps only native attribute is enough

Koc reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

[Serializer] Serialization versioning
9 participants
@micoli@carsonbot@antonkomarev@asispts@94noni@fabpot@nicolas-grekas@OskarStark@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp