You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$criteria = new Criteria();
$criteria->where($criteria->expr()->contains('roles', 'ROLE_ADMIN'));
$em = $this->container->get('doctrine')->getManager();
$data = $em->getRepository(User::class)->matching($criteria);
foreach ($data as $row) {
$row->getRoles(); // Force LAZY_LOAD
}
Current behavior
Generated SQL contains following where clause: WHERE t0.roles LIKE 's:12:\"%ROLE_ADMIN%\";'
Expected behavior
Where statement should not be serialized: WHERE t0.roles LIKE '%ROLE_ADMIN%'
or should be serialized before adding percent signs: WHERE t0.roles LIKE '%s:10:\"ROLE_ADMIN\";%'
The text was updated successfully, but these errors were encountered:
Hmm, seems correct behavior, since the conversion goes through SQL conversions in the DBAL type.
The problem is that it certainly isn't obvious to the consumer, but do imagine doing the same with a DateTime instance: a conversion would most certainly be expected.
Bug Report
Summary
When trying to use Criteria on array type of field, the value is incorrectly serialized.
Field definition:
Criteria usage:
Current behavior
Generated SQL contains following where clause:
WHERE t0.roles LIKE 's:12:\"%ROLE_ADMIN%\";'
Expected behavior
Where statement should not be serialized:
WHERE t0.roles LIKE '%ROLE_ADMIN%'
or should be serialized before adding percent signs:
WHERE t0.roles LIKE '%s:10:\"ROLE_ADMIN\";%'
The text was updated successfully, but these errors were encountered: