-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
Error while Encoding Generic Records using singleValueContainer #1565
Comments
Hello @sroebert, Sorry you met an area of the library that is not implemented. As you could see, this case was foreseen, but not handled because well it did not look like it would be ever needed. Then you came 😉 Adding the missing implementation would be nice, for sure. It's been a long time since this code was written, so I don't quite remember why it did not ship in a complete form. Do you think you could have a look? Otherwise I'll investigate. I hope we won't discover any serious difficulty. |
That was quick, amazing! |
It's OK. That was not "amazing", just the reaction of a maintainer who cares about the library users. We can still act as regular European people, don't you agree? No need to over-react. Don't misinterpret the nature of the help from other people. Your issue was spot-on. You provided the use case that was missing. Thank you for that. |
That’s just the way I say thank you, no over-reaction to be honest, just my regular European reaction 😅. Glad it was taken care of so promptly. |
Yeah, sorry, I was the one who was over the edge in my expression. 😬 I'll amend the PR a little bit, so that if the wrapped type conforms to |
Shipped in v6.28.0! Thanks for the feature request, @sroebert. |
What did you do?
I have some tables with columns I'm hiding from the actual public use (for syncing purposes). To still use the fields internally, I have a generic struct that wraps these types. I have done this before in several other projects for JSON parsing. The general way of implementing decoding is to use
singleValueContainer
, which is how I have it implemented.What did you expect to happen?
I expected encoding to work correctly.
What happened instead?
I got an error
single value encoding is not supported
.Looking into the code it contains the following comment:
Looking at the forum post, it seems like I am doing the right thing. It can also be solved with
try model.encode(to: encoder)
, but this does not seem correct. As the comments seem to suggest it might be something that still has to be implemented, I'm wondering how and if I can help.Environment
GRDB flavor(s): GRDB
GRDB version: 6.27.0
Installation method: SPM
Xcode version: 16.0 beta 2
Swift version: 6.0
Platform(s) running GRDB: iOS, macOS
macOS version running Xcode: 14.5
Demo Project
I don't have one, but can add if needed.
The text was updated successfully, but these errors were encountered: