mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3135: Unnecessary SELECT after updating of versioned table #3887
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (May 23, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user ikti:
When I update entity with version doctrine generates 2 SQLs:
INSERT INTO TableA (key, value) VALUES (1, 1);
SELECT version FROM TableA WHERE key = 1;
OR
UPDATE TableA SET value= 2, version = version 1 WHERE key = 1 AND version = 1;
SELECT version FROM TableA WHERE key = 1;
Not only second query is unnecessary (version value is always 1 after persisting and is always prev version 1 after successful update) but can also read incorrect value if row is updated between update and select statement. In this case entity manager will have outdated data, but most recent version.