-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Incomplete Entities after using FindOption 'fields' #4464
Comments
The problem you are describing was previously expected behavior (generally, e.g. for await orm.em.populate(a2, ['b']);
const test3 = (await a2.b.loadItems())[0].test3; // the `loadItems` call here is a no-op, as we previously loaded the collection via `em.populate()` Just to be sure, do you understand that the first |
Yes, I understand that this is the same entity, that is exactly the problem I'm having. The cached entity is missing some fields, but is not refreshed even though it is necessary in this case. If the entity was added with 'fields' to the cache, I'm always getting the same entity, even without 'fields'. The cache should probably keep track of this. |
Not really, the fix for this won't change that - you always get only one instance of the entity - the fix will be about loading the missing fields, so the previous instance will no longer be partially loaded. That's why I am asking if you understand this, as that is the core concept here, not a bug. The bug is only in the entity not being reloaded automatically with the If you want to have multiple entity instances, you need to use a separate EM fork (which is what the |
Yes, I understand that. I don't want multiple instances of the same entity. I'm not too familiar with the mikro-orm code, so my assumption with the cache is probably wrong. I simply want, that the missing fields are automatically loaded into the existing entity. |
I will keep this refactoring for v6, as it might be semi-breaking, the ordering of the collection items might change a bit (although from what I can see in the tests, it was rather wrong in v5 too, as the PK is used for ordering, even if it's a UUID, so probably fine, but let's stay on the safe side). Also there is one serialization problem that this refactoring introduces and is no longer present in v6 due to other refactorings already done in there. |
This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
So this ended up as a pretty painful refactoring, but it's finally working as expected. Closing as implemented in v6 via #4571. |
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
…4571) This unifies the population mechanism for to-many relations by using the `em.populate()` internally. Previously, the `Collection.init` (and methods using it, e.g. `loadItems`) were using custom implementation, which in some cases resulting in different results as opposed to `em.populate()`. With this PR, the `init` method is also using `em.populate`, yielding the same results as if you would populate the relation. Closes #4464
After loading an entity with the 'fields' FindOption Subsequent load operations will return incomplete entities.
See included testcase
The text was updated successfully, but these errors were encountered: