[Bug] ListOperation orderByRaw does not work when using mongodb
See original GitHub issueBug report
What I did
Tried to open a panel ??
What I expected to happen
To Open the panel ??
What happened
Mongodb Bad Sort Exception ??
What I’ve already tried to fix it
Commenting: $this->crud->query->orderByRaw($this->crud->model->getTableWithPrefix().‘.’.$column[‘name’].’ '.$column_direction); at list operation works.
Before when it had ‘$this->crud->query->orderBy($column[‘name’], $column_direction);’ It also worked (was change on one of last updates)
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version
the output is:
PHP VERSION:
PHP 7.4.9 (cli) (built: Aug 4 2020 11:51:50) ( NTS Visual C++ 2017 x64 ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies
LARAVEL VERSION:
v6.18.36@0fc371134524190fdf31f77c77bc73b096760f18
BACKPACK VERSION:
4.1.19@a47eeda32d08d0d47a3c820416c8a8f880752b80
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
orderByRaw Not working with jenssegers mongodb Laravel 5
This the remaining part of my query but whenever i use the below code for ordering by type in the sequel its gives...
Read more >Security Issue If You Use SQL Server (May Affect <0.02 ...
Cause & Effect. Because Backpack did not properly sanitize the input inside an orderByRaw() statement, our ListOperation technically allowed a ...
Read more >CHANGELOG.md · master · Bhayron Klivilan / CRUD · GitLab
#2528 fix installation problem - elfinder:publish command didn't work on ... should not throw error if the column does not exist; that way...
Read more >Laravel Quick Tip: orderByRaw() with ORDER BY FIELD
The “quick tip” is how to get the order by to work with Laravel. The usual function is ->orderBy('field', 'ASC|DESC'), but that won't...
Read more >CHANGELOG.md
Changelog All Notable changes to `Backpack CRUD` will be documented in this file ... and #2192 - order logic did not work with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for my delay been super bussy last hours. Raw Expressions fail when changing from relational to non relational database cause there are no sql at mongodb so they dont understand whats going on when making raw queries.
I took out the prefix inside the raw method and did not work, also tried different values for the method too.
I believe the package mongodb users use for implementing the elloquent interface called laravel-mongodb (by jessengers) does not implement a solution for raw functions since they are pure (or almost pure) sql sintax and not something the elloquent interface could fix. (Correct me if I’m wrong)
I know you have in mind just sql langages and its ok since Laravel does the same thing… but backpack been working like a charm with the laravel-mongodb package before, and I have been surprised that cruds read nested documents and everything perfectly.
Tomorrow I’ll check this again at my project, print error stack and post it here.
I’v just submited a PR that might address this. #3259
Let’s keep the discussion of how we are going to implement it in the PR thread.
I am going to close this in favor of the PR.
Wish you the best, Pedro