in my symfony 6.4 project I have defined the id in my user class as
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\Column(type: "uuid", unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?Uuid $id;
...
}
There is another entity to store user logins where the reference to the user is defined as
class UserLogin
{
...
#[ORM\ManyToOne(inversedBy: 'userLogins')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
...
}
I installed MariaDB 11.3.2 and my DATABASE_URL in .env is
DATABASE_URL="mysqli://...?serverVersion=mariadb-11.3.2&charset=utf8".
In the migrations created by "symfony console make:migration" I manually edited the type of user.id and userlogin.user_id to the type uuid which is available since maria 10.7.
Then I inserted the first user "manually" which means by handmade sql statement.
And now we come to the point. On a users login I do
$ul = new UserLogin();
$ul->setTs(new DateTime())
->setUser($token->getUser())
->setIp($request->getClientIp());
$this->em->persist($ul);
$this->em->flush();
This causes an error. The system tells me, that the foreign key on userlogin.user_id is invalid. This is caused by a value that is simply bullshit. Instead of giving a uuid, it writes a packed binary(16) thing.
After a little debug, I found out, that in the class Symfony\Bridge\Doctrine\Types\AbstractUidType within the method convertToDatabaseValue there is a line
$toString = $this->hasNativeGuidType($platform) ? 'toRfc4122' : 'toBinary';
that always results in 'toBinary'.
I already tried updating all libs via composer, but it seems as if symfony and doctrine don't know about native uuid types in maria (and mysql), even though 10.7 was first released in 2021.
Does anybody out there know how to solve that (without editing vendor files which is always a bad idea)?