-
Notifications
You must be signed in to change notification settings - Fork 284
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 #1541 - Optional attribute enhancement #1650
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try this. Hope its reasonably simple change.
I went with the @optional!In / Out proposal mentioned in the enhancement to maintain backward
I like the idea and I think we should also provide the according @ignore!In
, @ignore!Out
.
What I wonder about the chosen representation is if That would also reduce the pressure for global symbols with generic names at bit ( |
I believe |
So what would be the use case for |
What about for example some nullable field from the DB? Also I don't like In, Out, InOut aliases too much, but can't figure out the better way. Ideas are welcome. |
Gson library has @Expose annotation with boolean parameters: serialize and deserialize - looks worse than @optional!(In/Out/InOut). So as for me, your variant better.
This is the best option, as in most cases we have use a same logic, will be less code |
I've added possibility to set direction also to IgnoreAttribute. |
Please, could you merge it with master? This is need for my firebase cloud messaging library |
So what if we simply add an additional attribute |
@s-ludwig why not, or |
@s-ludwig so now it is:
But what about |
@tchaloupka maybe |
The issue with I have the feeling that maybe the whole
DB serialization would work without specifying a policy and API queries would be served with Of course, serialization policies need to be embraced by the code base (e.g. REST/web modules) before this is a generally applicable solution. |
And what about leaving So for example with the REST API, it could be: //define default API policy
@serializePolicy!MyPolicy @deserializePolicy!MyPolicy
interface IFoo
{
Bar[] getBars(); // use MyPolicy from the interface
// override interface policy to use FooPolicy instead
@serializePolicy!FooPolicy
Foo[] getFoos();
@deserializePolicy!FooPolicy
void setFoos(Foo[] foos);
} I don't see much benefit in the |
Any updates? |
@s-ludwig we need a consensus here to move forward :) |
@s-ludwig this is really desired feature ;) so... formal BUMP! :) |
Any news about this functionality? |
rebased and fixed some errors in untested cases |
Fixes vibe-d#1541 and is an alternative, simpler implementation of vibe-d#1650
Fixes vibe-d#1541 and is an alternative, simpler implementation of vibe-d#1650
the in/out argument for ignore is very useful, for optional it is imo pretty ambiguous. I made a separate PR adding embedNullable (#2405) which got merged which was an alternative implementation of this functionality. For the optional part I think this PR is no longer needed, but for the ignore this could be useful. |
Lets try this. Hope its reasonably simple change.
I went with the @optional!In / Out proposal mentioned in the enhancement to maintain backward compatibility. So @optional works as optional for deserialization and serialization.
@optional!In is optional just for deserialization and @optional!Out is optional for serialization.
There is also @optional!InOut which is the same as just @optional
Added some unittests which passes fine.
Also tried this with our codebase and it can really save some data (more than 50% in our case) so its pretty usefull.
Thanks @etcimon for pointing out the right place to look at.