Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3135

Unnecessary SELECT after updating of versioned table

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.2
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      PHP 5.5.9-1ubuntu4 (cli) (built: Apr 9 2014 17:11:57)

      Description

      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.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            ikti
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: