Database tab in debug toolbar is not working when we use binary Uuid in queries.
PHP Version
7.4
CodeIgniter4 Version
4.1.5
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
No response
What happened?
I have id fields type binary(16) in my all tables. To storing uuid i am using https://github.com/michalsn/codeigniter4-uuid package.
The issue I noticed is database tab in debug toolbar is not show when $query->debugToolbarDisplay(); return binary string in Display method of CodeIgniter\Debug\Toolbar\Collectors\Database.
I fixed it in my repo according to uuid package. OLD
public function display(): array
{
$data['queries'] = array_map(function (Query $query) {
return [
'duration' => ((float) $query->getDuration(5) * 1000) . ' ms',
'sql' => $query->debugToolbarDisplay(),
];
}, static::$queries);
return $data;
}
Changed
public function display(): array
{
$data['queries'] = array_map(static function (Query $query) {
$uuidService=service('uuid');
$FInalSQL=$query->debugToolbarDisplay();
//geting single quoted values
preg_match_all('/".*?"|\'.*?\'/', $FInalSQL, $matches);
$replaceAble=[];
foreach ($matches as $quoted) {
if(!empty($quoted)){
foreach ($quoted as $Qvalue) {
$binstr=str_replace("'","",$Qvalue);
///if values are binary then convert into uuid string
if(!ctype_print($binstr) && strlen($binstr)==16){
$replaceAble[]=['bin'=>$binstr,'str'=>$uuidService->fromBytes($binstr)->toString()];
}
}
}
}
// replace binary values with uuid string
foreach ($replaceAble as $value) {
$FInalSQL=str_replace($value['bin'],'<b>'.$value['str'].'</b>',$FInalSQL);
}
return [
'duration' => ((float) $query->getDuration(5) * 1000) . ' ms',
'sql' => $FInalSQL,
];
}, static::$queries);
return $data;
}
Steps to Reproduce
- add column as binary(16) in any table
- insert uuid as binary string manually or by any uuid package
- see database queries list in debug toolbar
Expected Output
codeigniter should display debug toolbar even there is binary string.
Anything else?
No response
I got:

6.86 ms | INSERT INTO `bin` (`text`, `bin`) VALUES ('test', '')
$model->insert(['text' => 'test', 'bin' => hex2bin('0102')]);
@atifriazmughal
codeigniter should display debug toolbar even there is binary string.
I think CI4 displays binary string as it is in debug toolbar. But we can't see it...