Allow the tags to work with uuids #3343
Replies: 5 comments
-
Can you explain why? And an example on why you need this? |
Beta Was this translation helpful? Give feedback.
-
Why?When creating modules with Doctrine entities and UUID, So using the current tags module will not be possible anymore for these custom modules,
Related issue with same problem"Search to work with uuids": #1962 |
Beta Was this translation helpful? Give feedback.
-
@tijsverkoyen I've also ran into this issue, and this combined with the search module is the main reason I'm not using them more often. Since if you want that to work you need to add a separate id just for this. Kinda overkill |
Beta Was this translation helpful? Give feedback.
-
@jeroendesloovere can you update the issue description so it contains the reasons why that you added in your comment? |
Beta Was this translation helpful? Give feedback.
-
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 tag index only works with integers
*
* @ORM\Column(type="integer")
*/
private $tagId;
/**
* @param int $tagId
* …
*/
public function __construct(
$tagId
…
) { Creating new instance of entity $myEntity = new MyEntity(
$this->myEntityRepository->getNextTagId(),
…
); Repository public function getNextTagId(): int
{
return (int) $this->getEntityManager()->createQueryBuilder()
->select('(COALESCE(MAX(e.tagId), 0) + 1) AS tagId')
->from(MyEntity::class, 'e')
->getQuery()
->getSingleScalarResult();
} |
Beta Was this translation helpful? Give feedback.
-
Type
Enhancement
Problem description
You can now only use integers as id's for the tags, 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 tags module will not be possible anymore for these custom modules,
since it requires the $otherId to be an
int
and we have achar
...Related issue with same problem
"Search to work with uuids": #1962
Beta Was this translation helpful? Give feedback.
All reactions