DDC-2914: [GH-910] [DDC-2310] Fix SQL generation on table lock hint capable platforms #3630

Closed
opened 2026-01-22 14:24:14 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 13, 2014).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of deeky666:

Url: https://github.com/doctrine/doctrine2/pull/910

Message:

SQL Server and SQL Anywhere use table lock hints for locking. ORM generates wrong SQL when used in conjunction with joins, in a table inheritance scenario or in a subquery. It places the table lock hints after the JOIN clauses, which is wrong. The table lock hints have to be placed after each table alias in the FROM clause.

_Example (current)_

SELECT t0.id FROM users t0 INNER JOIN profiles t1 ON t0.id = t1.user_id WITH (NOLOCK)

_Example (expected)_

SELECT t0.id FROM users t0 WITH (NOLOCK) INNER JOIN profiles t1 ON t0.id = t1.user_id

The testsuites fail big time at the moment because of that and I suppose ORM is more or less unusable at the moment for those platforms without this patch.

I needed to adjust a lot of tests which compared compiled DQL, to make use of the platforms specific lock hint clauses.
Also I did not add new tests because there are already so many tests, where this fails without this patch that this is not necessary IMO.

Originally created by @doctrinebot on GitHub (Jan 13, 2014). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of deeky666: Url: https://github.com/doctrine/doctrine2/pull/910 Message: SQL Server and SQL Anywhere use table lock hints for locking. ORM generates wrong SQL when used in conjunction with joins, in a table inheritance scenario or in a subquery. It places the table lock hints after the `JOIN` clauses, which is wrong. The table lock hints have to be placed after each table alias in the `FROM` clause. **_Example (current)**_ ``` sql SELECT t0.id FROM users t0 INNER JOIN profiles t1 ON t0.id = t1.user_id WITH (NOLOCK) ``` **_Example (expected)**_ ``` sql SELECT t0.id FROM users t0 WITH (NOLOCK) INNER JOIN profiles t1 ON t0.id = t1.user_id ``` The testsuites fail big time at the moment because of that and I suppose ORM is more or less unusable at the moment for those platforms without this patch. I needed to adjust a lot of tests which compared compiled DQL, to make use of the platforms specific lock hint clauses. Also I did not add new tests because there are already so many tests, where this fails without this patch that this is not necessary IMO.
admin added the Bug label 2026-01-22 14:24:14 +01:00
admin closed this issue 2026-01-22 14:24:14 +01:00
Author
Owner
@doctrinebot commented on GitHub (Jan 13, 2014): - is required for [DDC-2310: Recent changes to DBAL SQL Server platform lock hinting breaks ORM SqlWalker in DQL queries with joins](http://www.doctrine-project.org/jira/browse/DDC-2310)
Author
Owner

@doctrinebot commented on GitHub (Jan 31, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-910] was closed:
https://github.com/doctrine/doctrine2/pull/910

@doctrinebot commented on GitHub (Jan 31, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-910] was closed: https://github.com/doctrine/doctrine2/pull/910
Author
Owner

@doctrinebot commented on GitHub (Aug 18, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 18, 2014): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Nov 11, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-925] was assigned:
https://github.com/doctrine/doctrine2/pull/925

@doctrinebot commented on GitHub (Nov 11, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-925] was assigned: https://github.com/doctrine/doctrine2/pull/925
Author
Owner

@doctrinebot commented on GitHub (Nov 11, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-925] was closed:
https://github.com/doctrine/doctrine2/pull/925

@doctrinebot commented on GitHub (Nov 11, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-925] was closed: https://github.com/doctrine/doctrine2/pull/925
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3630