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

Enum serialisation issue with V7 #861

Closed
morganleroi opened this issue Sep 2, 2024 · 6 comments
Closed

Enum serialisation issue with V7 #861

morganleroi opened this issue Sep 2, 2024 · 6 comments
Assignees

Comments

@morganleroi
Copy link
Contributor

morganleroi commented Sep 2, 2024

There is another breaking change about JSON serialization we have seen later: the System.Text.Json serialization is set in the Algolia client to convert enums to string, while previously, they were converted to integers.

Since the Algolia client registers a global converter for doing this, it seems the only ways to adapt is either to set a custom converter on all enum properties of serialized models, or type the enum properties as int and adapt the code fetching them.

Originally posted by @fredericDelaporte in #852 (comment)

@morganleroi
Copy link
Contributor Author

@fredericDelaporte could you point me out what enum do you use ? In the v6 code base, there was only 3 real enum. All other properties that are now enum in v7 were string.

@morganleroi morganleroi self-assigned this Sep 2, 2024
@fredericDelaporte
Copy link

In our indexes data, we have properties typed as enums. That is our own business models enums. They were converted in the indexes as ints. Now, they are converted as strings.

@fredericDelaporte
Copy link

Additional consequences: we build the indexes with a .Net app but search them through JavaScript. So, JavaScript code expecting integers can not work. We have put converters on all our enum and enums array properties to get them serialized as int again.

(Sure enough, string values are more descriptive than integers, but they are also more susceptible to breaking changes due to renaming, and they cause the data to be heavier. Anyway, my point is just to notify a breaking change which should be included in the upgrade guide.)

@morganleroi
Copy link
Contributor Author

Hello @fredericDelaporte

Sorry for the late response. You are right, it's not an expected behaviour. We will publish a bug fix where the enum are persisted as int. We will also create a dedicated documentation about the enum behaviour + the Serialization changes.

@morganleroi
Copy link
Contributor Author

@fredericDelaporte

A new minor version has been released (7.4.0). This version fixes the enum issue.

Please note that your enum will be saved at int in this version.

@fredericDelaporte
Copy link

Thanks.

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

No branches or pull requests

2 participants