Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.16k stars 892 forks source link

[Bug] OrderBy column #5621

Closed preBit closed 2 months ago

preBit commented 2 months ago

Bug report

What I did

Update from v6.7.23 to v6.7.24 and above

What I expected to happen

OrderBy will work as in previous version

What happened

It works in v6.7.23 but after update to v6.7.24 and above it does not work with an error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."id" desc limit 25' at line 1
select
  `document`.*
from
  `document`
order by
  "document"."id" desc 

It probably should be something like this:

select
  `document`.*
from
  `document`
order by
  `document`.`id` desc 

This is the commit and part that changed: https://github.com/Laravel-Backpack/CRUD/commit/ab969cddf3023d629e51adc11b4aebbd9a2526f6

Specifically from this: https://github.com/Laravel-Backpack/CRUD/commit/ab969cddf3023d629e51adc11b4aebbd9a2526f6#diff-7b3eda922f455b17224d490ff2fb7ea813665afbc56acdcb6b0af29e70e8f9efL179

To: https://github.com/Laravel-Backpack/CRUD/commit/ab969cddf3023d629e51adc11b4aebbd9a2526f6#diff-7b3eda922f455b17224d490ff2fb7ea813665afbc56acdcb6b0af29e70e8f9efR181

Column that has error has specific orderLogic in column definition but the same orderLogic works with v6.7.23 and it does not with v6.7.24 and above

What I've already tried to fix it

Revert to v6.7.23

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

Yes from v6.7.24 and above

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.3.8

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, FFI, fileinfo, filter, ftp, gd, gettext, gmp, json, iconv, intl, SPL, ldap, mbstring, session, standard, odbc, pcntl, exif, mysqlnd, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, random, readline, Reflection, mysqli, shmop, SimpleXML, soap, sockets, sodium, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, xdebug, Zend OPcache

### LARAVEL VERSION:
11.20.0.0

### BACKPACK PACKAGE VERSIONS:
backpack/activity-log: 2.0.5
backpack/backupmanager: v5.0.4
backpack/basset: 1.3.5
backpack/calendar-operation: 1.0.6
backpack/crud: 6.7.24
backpack/editable-columns: 3.0.10
backpack/filemanager: 3.0.8
backpack/generators: v4.0.5
backpack/language-switcher: 1.0.1
backpack/logmanager: v5.0.2
backpack/medialibrary-uploaders: 1.2.0
backpack/menucrud: v4.0.1
backpack/newscrud: 5.1.0
backpack/pagemanager: 3.3.0
backpack/permissionmanager: 7.2.1
backpack/pro: 2.2.14
backpack/revise-operation: 2.0.0
backpack/settings: 3.1.1
backpack/theme-tabler: 1.2.11
pxpm commented 2 months ago

Hey @preBit thanks for the report 🙏

Just released 6.7.30 with the fix, our tests didn't caught this because we were asserting against hardcoded strings we created using the orderByRaw.

Let me know if you are still experiencing issues after the update 👍

Cheers

preBit commented 2 months ago

Thanks for the quick fix! 🙌 I tested the update, and the issue is resolved. Everything’s working perfectly now. Appreciate the support! 👍

Cheers