Open camohub opened 1 month ago
Probably called twice because the first time it needs to count the rows.
Ok although I am not sure about it. Its cursor not collection what query returns. But why the first sql is valid but second is broken? There is huge difference between them.
No clue, it sounds like something isn't right with the query that package produces. We just call the query do a ->count() first and a ->chunk() next, so this package isn't doing anything weird. As mentioned in https://github.com/SpartnerNL/Laravel-Excel/issues/4133#issuecomment-2142287963, you could try to do a ->clone() and see if that works for you
The clone() does not work in this case.
Having the same problem, but my query is little bit different I'm also passing Spatie/QueryBuilder, but there is union inside of it.
query() method runs twice, and on the second time it adds
order by table.id asc limit 1000 offset 0)
There is no opening for this part like SELECT (*) FROM
.
Removing unopened part that i mentioned first makes query work, but I can not do it via LaravelExcel methods
fixed by $finalQuery = DB::query()->fromSub($this->query->getEloquentBuilder(), 'temp') ->orderBy('id') ->select('*');
This is not fix. I would like to use Spatie QueryBuilder with its benefits around filtering.
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
What version of Laravel Excel are you using?
3.1.55
What version of Laravel are you using?
9
What version of PHP are you using?
8.2
Describe your issue
I have a job which is in queue. This job generate xls exports from query. The query method is below. The application uses also Spatie Querybuilder library which works great. As I found out the query() method is called twice which is weird (job runs only once). The first call generate valid SQL but the second call totaly ruin the sql from the builder. The query() method looks like
Thi is the log from the run
The second sql is invalid cause it refers to table which is not defined in sql.
Can somebody tell me what is wrong with this code?
This is full error trace
How can the issue be reproduced?
As I described above
What should be the expected behaviour?
As I descripbe above.