Skip to content
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

Uuid as a string type and updates without changes in the entity #281

Open
sarven opened this issue Nov 4, 2024 · 2 comments
Open

Uuid as a string type and updates without changes in the entity #281

sarven opened this issue Nov 4, 2024 · 2 comments
Labels

Comments

@sarven
Copy link

sarven commented Nov 4, 2024

Description

I've described the problem here: https://sarvendev.com/2024/10/uuid-orm-and-strange-deadlocks/

Steps to reproduce

  1. create an entity with string $id, mapped as uuid_type
  2. save this entity
  3. get the entity from the database and try to save it without changes
  4. UoW treats this entity as changed because original data contains a Uuid object (returned from UuidType::convertToPHPValue), and the actual data in the entity object contains a string
UPDATE table SET id = '2082c2e5-9eb5-43c1-809e-82265da220f0' WHERE id = '2082c2e5-9eb5-43c1-809e-82265da220f0'

Expected behavior

UuidType always returns the same type, and it isn't possible to make such a mistake. UuidType::convertToDatabaseValue should probably only accept UuidInterface as a parameter. I was thinking about implementing that, but it's a breaking change, so I am not sure about that. Perhaps the same problem occurs also with other types. I've just created this issue to open the discussion on how it could be fixed.

@sarven sarven added the bug label Nov 4, 2024
@ramsey
Copy link
Owner

ramsey commented Nov 26, 2024

Can you provide some code I can use to reproduce this issue? I've read the blog post and your steps here, but I want to make sure I'm able to fully reproduce the issue.

Thanks!

@sarven
Copy link
Author

sarven commented Dec 5, 2024

@ramsey I've just prepared a repository with a simple test to showcase this problem: https://github.com/sarven/uuid-bug-example/blob/main/tests/Repository/EntityRepositoryTest.php

UUID in the entity is represented as a string, it works, but during an update without any changes, it generates additional empty update.

UPDATE entities SET id = ? WHERE id = ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants