Allow the search to work with uuids #3346
carakas
started this conversation in
Ideas / Feature Requests
Replies: 1 comment
-
For now you can fix it with something like this Entity /**
* @var string
*
* @ORM\Id()
* @ORM\GeneratedValue(strategy="UUID")
* @ORM\Column(type="guid")
*/
private $id;
/**
* @var int
*
* we need this since the search index only works with integers
*
* @ORM\Column(type="integer")
*/
private $searchId;
/**
* @param int $searchId
* …
*/
public function __construct(
$searchId
…
) { Creating new instance of entity $myEntity = new MyEntity(
$this->myEntityRepository->getNextSearchId(),
…
); Repository public function getNextSearchId(): int
{
return (int) $this->getEntityManager()->createQueryBuilder()
->select('(COALESCE(MAX(e.searchId), 0) + 1) AS searchId')
->from(MyEntity::class, 'e')
->getQuery()
->getSingleScalarResult();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Type
Problem description
You can now only use integers as id's for the search, if switched to strings we can use UUID's
Why?
When creating modules with Doctrine entities and UUID,
$id is
char(36)
in combination with(DC2Type:guid)
.So using the current search module will not be possible anymore for these custom modules,
since it requires the $otherId to be an
int
and we have achar
...Beta Was this translation helpful? Give feedback.
All reactions