-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
global search fails when column name with relation has underscore #2324
Comments
I think this is an issue that can be fixed by setting the proper name on JS. Something like below. columns: [
...
{data: 'child_table.name', name: 'childTable.name'}
] -- Edit -- Found the docs: https://datatables.yajrabox.com/eloquent/relationships
|
On the other hand, I think we can consider adding columns: [
...
{data: 'child_table.name', name: 'childTable.name'}
]
// might work if we add Str::camel
columns: [
...
{data: 'child_table.name'}
] |
After considering your comments, I think perhaps it is better that the HTML builder applies the camel case when it assumed a default 'name' attribute for columns. Please see my PR in the laravel-datatables-html repo: |
Global search failing because EagerLoads collection contains relation names in CamelCase, whereas the founction is passing in the actual table name from the column name. e.g.
column name = child_table.name
Name in EagerLoad collection = childTable
compileQuerySearch in EloquentDataTable.php fails because it needs to convert relation name to camcel Case before calling isNotEagerLoaded:
suggest adding Str::camel call as follows:
Same issue could be fixed in resolveRelationColumn:
The text was updated successfully, but these errors were encountered: