-
-
Notifications
You must be signed in to change notification settings - Fork 859
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
Eager loading and accents issue #3196
Comments
I suspect this is a data error. You might have a user record without an employee record, making the relation null. |
Hey yajra, thanks for your response. All relations are good. The problem is that when I don't order by company name, this is the value for an user:
But when I order by company name (I can see the registry if I comment the column "company_relation"):
As you can see, the main ID and the name is not from the user, is from the company, there is no "company" value and the "employee" is null. All of that just for ordering by the company. The queries in both cases are like this, there is one more for the company if not ordering by it: Queries without ordering by company:
Queries with ordering:
|
If anyone is interested, I solved it like this:
Like this, both search and ordering works well since all the fields are present in every query. |
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Summary of problem or feature request
I have a relationship with a model called User that has a related model Employee, and Employee has a related model Company.
I'm trying to use Datatables while eager loading the three of them, but if I use ->get() when retrieving the Users, the accents search doesn't work well (if I have an employee called Menéndez, it doesn't appear when I search Menendez), but if I use it without the ->get(), it throws an error while ordering by company.
Code snippet of problem
This orders right but the accents doesn't work:
This works right with accents but ordering by company throws error:
The error is: "Exception Message: Attempt to read property "company_relation" on null"
Any idea of how can I fix this?
Thanks!
System details
The text was updated successfully, but these errors were encountered: