crnk-framework icon indicating copy to clipboard operation
crnk-framework copied to clipboard

CrnkClient transform zero into null when creating a resource

Open marciovmartins opened this issue 3 years ago • 5 comments

If you have a resource with a Long property and you pass 0 and try to create the resource via CrnkClient, the value is lost and becomes null.

I did not test it with other numeric types.

You can check and reproduce the error here: https://github.com/marciovmartins/crnk-zero-long-become-null

marciovmartins avatar May 19 '21 19:05 marciovmartins

I assume Long rather long? somewhere in the area of crnkclient/repository stubs/ResourceMapper there is a behavior that omits default values and only senda changes. there likely is a bug in there if Long is used.

remmeier avatar May 20 '21 09:05 remmeier

Yes, Long. Is this the desired outcome or is really a bug? Could the fix break something else?

marciovmartins avatar May 21 '21 06:05 marciovmartins

I found this code:

image image

Why the default value is not added to the attribute? What's the design decision behind that?

marciovmartins avatar May 21 '21 07:05 marciovmartins

cleaner POST requests. A shortcut to avoid having to use Long rather than long for such purposes. this is most notable when using the asciidoc doc generation. itnwill.give much cleaner examples.

ok-ish, maybe a bit borderline😬. but it should not have that behavior for non-primitive number types.

Marcio Vinicius @.***> schrieb am Fr., 21. Mai 2021, 09:01:

I found this code:

[image: image] https://user-images.githubusercontent.com/6377735/119095786-0373d580-ba13-11eb-93b5-0617778ffe3f.png [image: image] https://user-images.githubusercontent.com/6377735/119095491-a2e49880-ba12-11eb-878c-9bd3e22c7a1a.png

Why the default value is not added to the attribute? What's the design decision behind that?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crnk-project/crnk-framework/issues/813#issuecomment-845710631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DJFIWNEOOQ7YTEHY27NDTOYAOHANCNFSM45FKLS2A .

remmeier avatar May 21 '21 07:05 remmeier

Would be a good idea to add an annotation or configuration flag for this behavior? Like @EnableCleanerPost, @DisableCleanerPost, @CleanerPost(value = true) or something similar.

How the framework deals with this kind of configuration?

marciovmartins avatar May 21 '21 07:05 marciovmartins