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: product_type not included when null #996

Merged

Conversation

monsieurtanuki
Copy link
Contributor

Impacted files:

  • product.dart: made most fields as "includeIfNull: false", including product_type
  • product.g.dart: impact only on product_type

What

  • The product field "product_type" was ALWAYS included in the "toJson" conversion, even if null.
  • That had some problematic side effects on the server, that always saw a product_type provided for every "save product details" operation in Smoothie. And there's only one moment when this field should be sent: when we create the product. Afterwards, any save operation will be rejected if we populate the product_type, even with the same value.
  • Now the product field "product_type" is only populated in the "toJson" conversion when it's not null, which only happens in Smoothie when we create the product in the correct OxF server.
  • Beyond that, in order to avoid similar errors, a general code clean up should be performed around the "includeIfNull" clause for all classes, but that's another story.

Part of

Impacted files:
* `product.dart`: made most fields as "includeIfNull: false", including product_type
* `product.g.dart`: impact only on product_type
Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

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

@monsieurtanuki monsieurtanuki merged commit 5ba66a0 into openfoodfacts:master Nov 21, 2024
4 of 5 checks passed
@monsieurtanuki
Copy link
Contributor Author

Thank you @teolemon for your review!

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

Successfully merging this pull request may close these issues.

2 participants