You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a hybrid setup with MySQL and MongoDB.
Eager Loading latest item of relation is not working correctly. I want to load a list of customers with their latest metrics (by date) eager loaded. Instead of loading the latest metric for every customer, it just loads the latest metric in total.
Steps to reproduce
The Customer Class (Mysql):
class Customer extends Model
{
use HybridRelations;
public function metrics()
{
return $this->hasMany(Metrics::class);
}
}
@divine didn't I open a new issue? Maybe the problem is already known, but the other issue was closed in 2018 without any reason and it still doesn't seem to work.
I have the same issue with laravel 8 and jenssegers/mongodb 3.8.x
it works only with belongsTo relation
hasone or has many return empty response cause the foreign key and primary id is objectID while package search in collection with string type
Description:
I have a hybrid setup with MySQL and MongoDB.
Eager Loading latest item of relation is not working correctly. I want to load a list of customers with their latest metrics (by date) eager loaded. Instead of loading the latest metric for every customer, it just loads the latest metric in total.
Steps to reproduce
The Customer Class (Mysql):
The Metrics Class (Mongodb):
The code that loads the data:
I also tried to use
first()
instead oflimit(1)->get()
, but that led to the same result.Expected behaviour
It should return all customers with their latest metrics, similar to this:
Actual behaviour
Only the newest metric of all customers is returned, which results, that most customers have empty metrics:
@jenssegers
seems to be the same problem as this issue: #1042 (comment)
The text was updated successfully, but these errors were encountered: