-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DBAL] Bigint showing up as actual integer in UOW changesets #6650
Comments
@KDederichs please provide a sample script that uses only the DBAL to reproduce your issue. |
@morozov I updated the original link to only use vanilla DBAL |
The link in the description points to a Symfony project. What link are you referring to? |
Yeah that, honestly that's the only way I ever used doctrine so if you need something REALLY standalone I'd have to dig into it, but it only seems to happen if you use a Symfony UUID for primary key anyways so not sure if I can get you a purely doctrine one (maybe it's more of an ORM issue? Not sure where the distinction lies when reporting them tbh). In any case it's a rather simple test case: public function testGetBar(): void
{
$bar = new Bar();
/** @var EntityManagerInterface $em */
$em = self::getContainer()->get(EntityManagerInterface::class);
$em->persist($bar);
$em->flush();
$em->clear();
$bar2 = $em->getRepository(Bar::class)->find($bar->getId());
$em->getUnitOfWork()->computeChangeSet($em->getClassMetadata(Bar::class), $bar2);
var_dump($em->getUnitOfWork()->getEntityChangeSet($bar2));
self::assertEmpty($em->getUnitOfWork()->getEntityChangeSet($bar2));
}
} with this as entity: <?php
namespace App\Entity;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[Entity]
class Bar
{
#[Id, Column(type: UuidType::NAME)]
private Uuid $id;
#[Column(type: 'bigint', nullable: false, options: ['default' => "0"])]
private ?string $baz = '0';
public function getId(): Uuid
{
return $this->id;
}
public function __construct()
{
$this->id = Uuid::v7();
}
public function getBaz(): ?string
{
return $this->baz;
}
public function setBaz(?string $baz): self
{
$this->baz = $baz;
return $this;
}
} Based on that can you maybe tell me if it's the right repo to report this in the first place? |
Bug Report
Summary
I've run into this while writing tests with foundry (already confirmed with them it's not on their end so I'll bring it up here):
When you have an entity that uses an Uuid as primary key (or maybe has any non primitive as value, not sure but it's easily replicable with Uuid PKs) and then add a bigint value to that entity it will for some reason generate a change UOW changeset on that bigint value from 0 to "0" even though there never was a non string value assigned to it.
This behavior seems to have started somewhere in DBAL 4 since it's still working correctly in DBAL 3
If you don't think it's DBAL related but something Foundry does please let me know
Current behavior
It will incorrectly somewhere assign an actual integer to the bigint variable and then try to change that to string in UOW
Expected behavior
It shouldn't need to convert it.
How to reproduce
https://github.com/KDederichs/sf-reproducer/tree/foundy/unsaved_changes
The text was updated successfully, but these errors were encountered: