Closed Mirko-Tebaldi closed 2 years ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
Downgrade to "backpack/crud": "5.4.1",
Failed. Same issue
Downgrade to "backpack/crud": "5.4.0",
Failed. Same Issue
Downgrade to "backpack/crud": "5.3.13",
Issue not present.
So 5.4.0 create some kind of regression.
I suggest investigating this function, but I'm not so sure
Our specific use case is particular: our customer wants table 'joborders' ordered by customer name, that is an attribute in a related table
So we added this to our Controller
$this->crud->addColumn([
'name' => 'company_name',
'entity' => 'customer',
'attribute' => 'company_name',
'label' => 'Cliente',
'type' => 'relationship',
'orderable' => true,
'orderLogic' => function ($query, $column, $columnDirection) {
return $query
->leftJoin('customers', 'joborders.customer_id', '=', 'customers.id')
->orderBy('customers.company_name', $columnDirection)
->select('joborders.*')
;
}
]);
I also tried
$this->crud->model->setKeyName("joborders.id");
But it generates a query with doubled table name, damn ...
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'joborders.joborders.id' in 'order clause' (SQL: select `joborders`.*, `customers`.`company_name` from `joborders` left join `customers` on `joborders`.`customer_id` = `customers`.`id` order by `customers`.`company_name` asc, joborders.joborders.id DESC limit 10)
Fix suggested:
File: vendor/backpack/crud/src/app/Library/CrudPanel/Traits/Query.php
Change ROW 326 from
$outerQuery = $outerQuery->fromSub($subQuery->select($this->model->getKeyName()), $this->model->getTableWithPrefix());
to
$outerQuery = $outerQuery->fromSub($subQuery->select($this->model->getTableWithPrefix() . "." . $this->model->getKeyName()), $this->model->getTableWithPrefix());
I have NO idea of collateral effects of this.
No side effects that's the perfect solution, I should had implemented it that way, I am working on it and will submit the PR in a few moments.
Thanks and sorry for the bad experience @realtebo 🙏
thanks for very fast fixing.
Can I suggest to add a test, in your suite, to handle situation where a list operation is populated and sorted with something from a related field?
Can I suggest to add a test, in your suite, to handle situation where a list operation is populated and sorted with something from a related field?
I second that 😀
PS. Pedro's submitted the fix and it's merged and tagged, so a composer update
should fix it for everybody.
Bug report
What I did
I just upgraded to 5.4.2 from 5.3.12
What I expected to happen
Nothing else than good things
What happened
In a list I got this error that was not happening previously
What I've already tried to fix it
I am trying to rollback a minor at time to understand when and what the upgrade broke my code
Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there?Yes
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is: