Skip to content

Fix inserted _id on association of child to parent in EmbedsMany #1545

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

Closed
wants to merge 1 commit into from

Conversation

timsweb
Copy link

@timsweb timsweb commented Jun 17, 2018

When an object is associated to parent in associateNew, a Mongo ID is created and added to the model regardless of the key set on the model. This commit changes the behaviour to only add the _id in instances where the primary key is set to be _id. This may be a breaking change if code is depending on this behaviour; but the existing behaviour is undocumented.

Fixes #1310

When an object is associated to parent in `associateNew`, a Mongo ID is created and added to the model regardless of the key set on the model. This commit changes the behaviour to only add the _id in instances where the primary key is set to be `_id`. This _may_ be a breaking change if code is depending on this behaviour; but the existing behaviour is undocumented.
@anthonyvancauwenberghe
Copy link
Contributor

I was going to submit a pull request that fixes this aswell. @jenssegers should we check if the primary key is actually set aswell? Or are there usecases for inserting records that do not have a primary key set?

@divine
Copy link
Contributor

divine commented Jan 22, 2020

Should be closed, fixed and merged in #1740

cc @Smolevich

Thank you for your contribution!

@Smolevich Smolevich closed this Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a model without a _id?
4 participants