Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-2310

Recent changes to DBAL SQL Server platform lock hinting breaks ORM SqlWalker in DQL queries with joins


    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.3.3, 2.5
    • Component/s: ORM
    • Security Level: All
    • Environment:
      SQL Server


      The SQL Server platform throws an error when you try to run DQL with JOIN statements.

      The breaking change was in the DBAL SQL Server platform – it was changed to add a ' WITH (NOLOCK)' to the appendLockHint function. Change was in this rev. The change in DBAL is not wrong, it just highlighted the bug in the ORM...

      The ORM SqlWalker runs the appendLockHint function against a generated FROM / JOIN clause in the walkFromClause func here. This is actually the wrong place to append lock hints. This is generating the FROM clause like:

       FROM foo f0_ LEFT JOIN foo_bar f1_ ON f0_.id = f1_.foo_id LEFT JOIN bar b2_ ON f1_.bar_id = b2_.id WITH (NOLOCK)

      When it should actually generate something like:

       FROM foo f0_ WITH (NOLOCK) LEFT JOIN foo_bar f1_ WITH (NOLOCK) ON f0_.id = f1_.foo_id LEFT JOIN bar b2_ WITH (NOLOCK) ON f1_.bar_id = b2_.id

      It should append lock hints after the table alias.

      I think the only reason this hasn't shown up before is that the other lock hint types haven't been applied in this way before, if at all.

        Issue Links



            • Assignee:
              beberlei Benjamin Eberlei
              wschalle Bill Schaller
            • Votes:
              0 Vote for this issue
              6 Start watching this issue


              • Created: