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

fix(objectschema)!: omit id from schema returned by without + only #195

Merged

Conversation

esatterwhite
Copy link
Contributor

the methods without and only return new schema objects with the same id that was found on the original. In terms of schema reuse, this creates two different schemas with the same id which is technically invalid. Additionally, it was not possible to set the id property on an object schema that had properties defined. This problem originates from the setattribute function which will always set the attribute on the schema properties if they are defined. In the case of the object schema, this is almost always the case. This changes the id function on the object schema to always generate a new schema with the id set on the object schema rather than its properties

BREAKING CHANGE: ObjectSchema.id() will always set the id on the root object
BREAKING CHANGE: ObjectSchema.without() will omit id from the return schema
BREAKING CHANGE: ObjectSchema.only() will omit id from the return schema

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@esatterwhite
Copy link
Contributor Author

anything left to do here? or does anyone else need to look at this?

@esatterwhite
Copy link
Contributor Author

@aboutlo ?

@esatterwhite
Copy link
Contributor Author

@aboutlo thoughts?

@aboutlo
Copy link
Collaborator

aboutlo commented Oct 1, 2022

Hey @esatterwhite thank you for your PR 💪

Could you add the changes in the documentation aka:

  • add the documentation tags and explain the different behaviours
  • update the doc by running npm run doc and commit the markdown updated

Then I can merge and make a release with these breaking changes and the drop of the old node versions

@esatterwhite esatterwhite force-pushed the esatterwhite/193-remove-id-with-clone branch from 239fe77 to 088ad2d Compare October 3, 2022 14:43
the methods without and only return new schema objects with the same id
that was found on the original. In terms of schema reuse, this creates
two different schemas with the same id which is technically invalid.
Additionally, it was not possible to set the id property on an object
schema that had properties defined. This problem originates from the
setattribute function which will always set the attribute on the
schema properties if they are defined. In the case of the object schema,
this is almost always the case. This changes the id function on the
object schema to always generate a new schema with the id set on the
object schema rather than its properties

BREAKING CHANGE: ObjectSchema.id() will always set the id on the root object
BREAKING CHANGE: ObjectSchema.without() will omit id from the return schema
BREAKING CHANGE: ObjectSchema.only() will omit id from the return schema
@esatterwhite esatterwhite force-pushed the esatterwhite/193-remove-id-with-clone branch from 088ad2d to 16a1bd4 Compare October 3, 2022 14:47
@esatterwhite
Copy link
Contributor Author

@aboutlo Done

@@ -1 +1 @@
v12.14.0
v14.19.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't actually work on node 12 anymore

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3175096857

  • 0 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 3163920994: 0.0%
Covered Lines: 403
Relevant Lines: 403

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3175096857

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 3163920994: 0.0%
Covered Lines: 403
Relevant Lines: 403

💛 - Coveralls

@aboutlo aboutlo merged commit 075b699 into fastify:master Oct 3, 2022
@aboutlo aboutlo mentioned this pull request Oct 3, 2022
2 tasks
This pull request was closed.
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