Closed abbasmashaddy72 closed 2 months ago
Says SQLSTATE[42S22]: Column not found: 1054 Unknown column 'localities.name' in 'field list'
Try AS localities_name so not to conflict with users.name.
Says
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'localities.name' in 'field list'
Try AS localities_name so not to conflict with users.name.
When Using' AS '
as per user suggestion getting this error
Error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'patients.locality.name' in 'field list'
Code:
Column::name('locality.name as locality_name')
Detailed Report: https://flareapp.io/share/LPdda1gP#F70
From My Point of view We Have to change that in export function. @tomshaw
@abbasmashaddy72 You may have to build your query with a left join.
Okay
It is working fine when I am using join but not when using relationship @tomshaw
@abbasmashaddy72 Currently working weekdays. Checkout src/Http/Livewire/LivewireDatatable.php
specifically methods export() and getExportResultsSet() probably an easy fix.
I am on it
The issue is not actually with export but with re-render process. When we run export the query will be built twice. The second time it fails because join is not added. It is not added because second time getSelectStatements function is called columns already have select
prop
if ($column->select) { return $column; }
Then as a side effect, resolveColumnName doesn't get called and join is not added.
It is easy to test out, if you delete from a view file the entire html where $this->results is mentioned you will have a table with export button only and export will work. Also if you comment out the part of the code that checks if $column already has select prop set, it will again work (this time both render and export)
I had the same issue and did some debugging to come to this. Maybe I could even prepare a PR, but I need more time to figure out if actually the bug is somewhere else, maybe columns should be reset after certain action? @tomshaw let me know if this rings a bell
It is correct, the issue is exactly same
did you find any solution on it @kirba
@abbasmashaddy72
PR #516 should fix it.
As mentioned in the PR, there is a workaround, you can define join clause in builder function and it will be fine
Okay Thanks Bro
This Issue Only Occurs when my relation table also has the same column name as that of other related column table
Example: My Table Patient Has a name field column & My Table Locality also Has a name filed column
So at the Time of Export It is Trowing the Error Column not Found
If we fix it Finally, the issue will be solved.
Note: When I am using same relation with count method in number column, it works fine
users.name:count
Also, It's working fine with relation if all column names are different.Please Check This Link: https://flareapp.io/share/LPdda1gP#F70
The Above Link will give more Detailed Report on what we are having the issue on Export @marksalmon @thyseus @tomshaw @trippo @renardudezert @mrsid18