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: Deserialization errors when using symfonia and creating a user with chorus #559

Closed
wants to merge 2 commits into from

Conversation

bitfl0wer
Copy link
Member

I have encountered the error Deserialization error: Found String \"0\", expected u8 when tinkering with chorus and symfonia. The fix for this is trivial, when using serde_aux, which we already are.

My thought is to apply these deserialize_option_number_from_string and deserialize_number_from_string onto all fields in entity structs, where the field is of a numeric type. What do you think of this, @kozabrada123?

@bitfl0wer bitfl0wer added this to the 0.17.0 milestone Sep 2, 2024
@kozabrada123
Copy link
Member

I see no real problems with this, however, wouldn't it be better to fix the serialization in symfonia?

@kozabrada123
Copy link
Member

or are all postgres uints always serialized as strings, in case they are too large?

@bitfl0wer
Copy link
Member Author

or are all postgres uints always serialized as strings, in case they are too large?

Postgres does not have sized unsigned integers - hence my crate sqlx_pg_uint.

I see no real problems with this, however, wouldn't it be better to fix the serialization in symfonia?

What is weird is, that symfonia just uses the User type from chorus, then wraps that in the poem Json type, and sends that over the wire with, as far as I can tell, no additional modifications. Needs further investigation I think

@kozabrada123
Copy link
Member

Postgres does not have sized unsigned integers - hence my crate sqlx_pg_uint.

Uhm yes, I meant, are those types from your crate meant to be serialized as strings? xD

What is weird is, that symfonia just uses the User type from chorus, then wraps that in the poem Json type, and sends that over the wire with, as far as I can tell, no additional modifications. Needs further investigation I think

We should check, does just using serde_json also produce strings for those types?

@bitfl0wer
Copy link
Member Author

Now that you mentioned it, sqlx_pg_uint uses the De-/Serialize implementations of the underlying BigInt type. Those are very likely Strings and thus the cause of the problem. I'll update the crate and override the De-Serializations by using proper uint types there as well

@bitfl0wer
Copy link
Member Author

Fixed by updating sqlx_pg_uint 👍

@bitfl0wer bitfl0wer closed this Sep 2, 2024
@bitfl0wer bitfl0wer deleted the fix/deserialization-errors-symfonia branch September 2, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants