Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Bug] Search is not working correctly #930

Closed tringuyenduc2903 closed 2 months ago

tringuyenduc2903 commented 2 months ago

Bug report

What I did

In Relationship field

            CRUD::field('lesson')
                ->label(ucfirst(trans('validation.attributes.lesson')))
                ->inline_create(true)
                ->tab(trans('Detail'));

or Select2 Ajax filter

        CRUD::filter('course_id')
            ->label(trans('validation.attributes.course'))
            ->type('select2_ajax')
            ->values(route('lesson.fetchCourse'))
            ->select_attribute('title')
            ->method('POST');

What I expected to happen

Find 1 with 1 short paragraph ("C#") to get the list ("C# Progamming", "C# Course",...)

What happened

  - Upgrading backpack/basset (1.3.0 => 1.3.1): Extracting archive
  - Upgrading backpack/crud (6.7.5 => 6.7.6): Extracting archive

Quay phim màn hình từ 12-04-2024 22:50:45.webm

What I've already tried to fix it

  - Downgrading backpack/basset (1.3.1 => 1.3.0): Extracting archive
  - Downgrading backpack/crud (6.7.6 => 6.7.5): Extracting archive

Quay phim màn hình từ 12-04-2024 22:49:22.webm

Is it a bug in the latest version of Backpack?

After I run backpack composer update backpack/crud the error it still persists

Backpack, Laravel, PHP, DB version

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

### PHP VERSION:
8.3.4

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, igbinary, imagick, imap, intl, ldap, exif, msgpack, mysqli, pcov, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, swoole, Zend OPcache, xdebug

### LARAVEL VERSION:
11.3.1.0

### BACKPACK PACKAGE VERSIONS:
backpack/activity-log: 2.0.3
backpack/backupmanager: v5.0.2
backpack/basset: 1.3.1
backpack/crud: 6.7.6
backpack/filemanager: 3.0.7
backpack/generators: v4.0.5
backpack/language-switcher: 2.0.0
backpack/logmanager: v5.0.1
backpack/medialibrary-uploaders: 1.2.0
backpack/permissionmanager: 7.2.0
backpack/pro: 2.1.12
backpack/revise-operation: 2.0.0
backpack/theme-tabler: 1.2.8
backpack/translation-manager: 1.0.2
pxpm commented 2 months ago

Hello @tringuyenduc2903

The only noticeable change that can link to that was the fact that we introduced the possibility to add mariadb as a sql connection as that was handled by mysql connection previously in Laravel 10.

I think it was you who asked for that, so I assume you are using it. Did you change any configuration of the mariadb connection that comes by default with Laravel ?

At first glance they seem pretty much the same: image

If previously worked with mysql, even if under the hood it used mariadb, I don't think any changes we did could have affected that, unless you changed some configurations that we are not aware in your mariadb connection.

Let me know if that helps.

Cheers

tringuyenduc2903 commented 2 months ago

I'm temporarily fixing it this way, but I still haven't found out the specific cause.

In the previous version, because MariaDB has not been added to the list, it can still work. Only MariaDB Currently, the error is on both MySQL and MariaDB

In vendor/backpack/crud/src/app/Models/Traits/HasRelationshipFields.php file

    private static function isSqlConnection()
    {
        $instance = new static();

        $driver = $instance->getConnection()->getConfig()['driver'];

        $drivers = CRUD::getSqlDriverList();
        $mariadb = array_search('mariadb', $drivers);
        $mysql = array_search('mysql', $drivers);
        unset(
            $drivers[$mariadb],
            $drivers[$mysql]
        );

        return in_array($driver, $drivers);
    }
pxpm commented 2 months ago

Hey @tringuyenduc2903 thanks for the report.

I see you are using FetchOperation, and the issue reported here may be related with that fact, and not specifically with mariadb.

I've just pushed a fix to PRO in 2.1.13 that adds varchar and char to the text column types. In previous versions those columns were converted to type string by dbal.

A composer update should get you the updated version.

Let me know if that works for you.

Cheers

tringuyenduc2903 commented 2 months ago

Thanks for your effort, my issue has been resolved