Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.

Conversation

@petecocoon
Copy link

Hi @yfilali
I have made some enhancements to OneToMany serialize and deserialize.

  1. before this modification save a relationship with the same key duplicated were allowed but at resolve() time boto3 will raise an error with "Provided list of item keys contains duplicates"
    see commit #64235f9c5731d5b5a1d836f32d422fb052586cca

  2. I've added the uniqueness parameter to OneToMany constructor
    if is not set or is set to False if you set a duplicated item in a relation nothing is done
    if you set uniqueness='throws' an exception will be raised.
    if you set uniqueness='clean' the keys in relation will be deduplicated

Feel free to modify or makes some changes

Piero Bozzolo added 3 commits August 8, 2019 09:19
1) uniqueness=False
You can repeat a key in a relationship

2) uniqueness='throws'
If a key is repeated an exception is raised

3) uniqueness='clean'
Duplicated keys will be cleaned, for example if your keys are [1,2,1], only [1,2] will be serialized
@petecocoon
Copy link
Author

hi @yfilali any news on this?

@yfilali
Copy link
Owner

yfilali commented Aug 23, 2019

Hi @petecocoon,

Thanks for this. The changes look good to me, but my first instinct would have been to not allow duplicates at all and simply de-dupe on the fly which I think makes intuitive sense. I am ok with the behavior you implemented as long as the default is uniqueness='clean'.

Any chance you have time to add a blurb to the readme about this? maybe below Limitations as a new section?

If not, I'll try to find some time this weekend to go through it in more detail and document before merging it in.

Thanks a bunch for the contrib!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants