Skip to content

Commit 1bc8f39

Browse files
committed
fix check for json column type
1 parent c2c4847 commit 1bc8f39

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/app/Library/CrudPanel/Traits/Search.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Backpack\CRUD\ViewNamespaces;
66
use Carbon\Carbon;
7-
use Doctrine\DBAL\Types\JsonType;
87
use Validator;
98

109
trait Search
@@ -113,7 +112,7 @@ public function applyDatatableOrder()
113112
if (method_exists($this->model, 'translationEnabled') &&
114113
$this->model->translationEnabled() &&
115114
$this->model->isTranslatableAttribute($column['name']) &&
116-
is_a($this->model->getConnection()->getDoctrineColumn($this->model->getTableWithPrefix(), $column['name'])->getType(), JsonType::class)
115+
$this->isJsonColumnType($column['name'])
117116
) {
118117
$this->orderByWithPrefix($column['name'].'->'.app()->getLocale(), $column_direction);
119118
} else {
@@ -395,10 +394,10 @@ public function getEntriesAsJsonForDatatables($entries, $totalRows, $filteredRow
395394
}
396395

397396
return [
398-
'draw' => (isset($this->getRequest()['draw']) ? (int) $this->getRequest()['draw'] : 0),
399-
'recordsTotal' => $totalRows,
397+
'draw' => (isset($this->getRequest()['draw']) ? (int) $this->getRequest()['draw'] : 0),
398+
'recordsTotal' => $totalRows,
400399
'recordsFiltered' => $filteredRows,
401-
'data' => $rows,
400+
'data' => $rows,
402401
];
403402
}
404403

@@ -413,4 +412,9 @@ public function getColumnWithTableNamePrefixed($query, $column)
413412
{
414413
return $query->getModel()->getTable().'.'.$column;
415414
}
415+
416+
private function isJsonColumnType(string $columnName)
417+
{
418+
return $this->model->getDbTableSchema()->getColumnType($columnName) === 'json';
419+
}
416420
}

0 commit comments

Comments
 (0)