[CORE][DB] Fix error in regex that prevented selecting collumns that are named the same way a column is

This commit is contained in:
Hugo Sales 2021-11-01 21:04:49 +00:00
parent 839fa070c7
commit 1960f6944f
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -68,7 +68,7 @@ class DB
{
$all = self::$em->getMetadataFactory()->getAllMetadata();
foreach ($all as $meta) {
self::$table_map[$meta->getTableName()] = $meta->getMetadataValue('name');
self::$table_map[$meta->getTableName()] = $meta->getMetadataValue('name');
self::$class_pk[$meta->getMetadataValue('name')] = $meta->getIdentifier();
}
}
@ -88,7 +88,7 @@ class DB
*/
public static function dql(string $query, array $params = [], array $options = [])
{
$query = preg_replace(F\map(self::$table_map, fn ($_, $s) => "/\\b{$s}\\b/"), self::$table_map, $query);
$query = preg_replace(F\map(self::$table_map, fn ($_, $s) => "/(?<!\\.)\\b{$s}\\b/"), self::$table_map, $query);
$q = new Query(self::$em);
$q->setDQL($query);