Skip to content

Commit

Permalink
Merge pull request #5487 from Laravel-Backpack/fix-json-column-type-i…
Browse files Browse the repository at this point in the history
…nfering

Fix json column type infering after removal of dbal
  • Loading branch information
pxpm committed Apr 4, 2024
2 parents c2c4847 + 24dfe6e commit d0e43cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/Library/CrudPanel/Traits/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Backpack\CRUD\ViewNamespaces;
use Carbon\Carbon;
use Doctrine\DBAL\Types\JsonType;
use Validator;

trait Search
Expand Down Expand Up @@ -113,7 +112,7 @@ public function applyDatatableOrder()
if (method_exists($this->model, 'translationEnabled') &&
$this->model->translationEnabled() &&
$this->model->isTranslatableAttribute($column['name']) &&
is_a($this->model->getConnection()->getDoctrineColumn($this->model->getTableWithPrefix(), $column['name'])->getType(), JsonType::class)
$this->isJsonColumnType($column['name'])
) {
$this->orderByWithPrefix($column['name'].'->'.app()->getLocale(), $column_direction);
} else {
Expand Down Expand Up @@ -413,4 +412,9 @@ public function getColumnWithTableNamePrefixed($query, $column)
{
return $query->getModel()->getTable().'.'.$column;
}

private function isJsonColumnType(string $columnName)
{
return $this->model->getDbTableSchema()->getColumnType($columnName) === 'json';
}
}

0 comments on commit d0e43cb

Please sign in to comment.