FastEasyMapping icon indicating copy to clipboard operation
FastEasyMapping copied to clipboard

Primary key not required

Open jcavar opened this issue 7 years ago • 4 comments

Hello!

I understand data validation is more of general concern and maybe out of scope for this librarty. There were also few questions asked before, however I am interested specifically about primaryKey attribute.

If you specify it for your mapping, does it make sense to create object when not in representation? At the moment framework just checks and if not in, it ignores it, but it sounds to me like this should result in error (or nil).

What are your thoughts?

jcavar avatar Aug 16 '18 13:08 jcavar

Good day, @jcavar! Can you describe some real use case, because I don't fully understand what you mean by

just checks and if not in, it ignores it

Thanks!

dimazen avatar Aug 16 '18 17:08 dimazen

If we get invalid data without identifier, FEM inserts object without identifier.

What I meant by that is this part of code:

https://github.com/Yalantis/FastEasyMapping/blob/master/FastEasyMapping/Source/Deserializer/FEMDeserializer.m#L120-L122

My feeling is that there should be else case where you return nil.

jcavar avatar Aug 17 '18 06:08 jcavar

@jcavar oh, I got it. Can you check out branch required-pk? Will it help if you gonna use this version? If so, I'll roll out a release

dimazen avatar Aug 17 '18 09:08 dimazen

That looks like it, yes!

jcavar avatar Aug 17 '18 11:08 jcavar