Wrong createInstance in hasMany associations. MongoDB.#479
Closed
Kreees wants to merge 2 commits intodresende:masterfrom
Closed
Wrong createInstance in hasMany associations. MongoDB.#479Kreees wants to merge 2 commits intodresende:masterfrom
Kreees wants to merge 2 commits intodresende:masterfrom
Conversation
Collaborator
|
I recently hit some weird hasmany mongo test failures, might have been caused by the same issue.. |
Contributor
Author
|
Actually proper test should do some kind of instanceOf check. Ex. There are two options to fix this issue.
|
Contributor
|
Hello, What about this issue ? I have the same... I have just apply your correction in the last version of this module and it's seems ok. Why this solution is not integrated in the current version ? |
Collaborator
|
Hi, I've rebased this and merged to master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello.
In case of hasMany association in return of instance
getAccessor(ex. getPets) you get instances of wrong models with MongoDB driver. InMany.jsmoduleextendInstancefunction (within createInstance call) utilizesDriver.hasManyon mongodb driver./lib/Association/Many.js
But passed
createInstanceargument is supposed for current model instance creation, not for associated model. Hence all associated objects become wrapped in wrong model class.That case is swallowed by test due to checks are accomplished by presence and
nameproperty presented in both models (Person and Pet)/test/integration/association-hasmany.js
At the same time everything works fine with SQL drivers (checked with sqlite).
I would have made a pool request, but in that case
createInstancedefinition in/ib/Model.jsis hidden by closure and not accessible directly from model.