[PR #910] [MERGED] [DDC-2310] [DDC-2675] Fix SQL generation on table lock hint capable platforms #8887

Open
opened 2026-01-22 16:02:09 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/910
Author: @deeky666
Created: 1/13/2014
Status: Merged
Merged: 1/31/2014
Merged by: @beberlei

Base: masterHead: DDC-2310


📝 Commits (1)

  • b9ff877 fix SQL generation on table lock hint capable platforms

📊 Changes

5 files changed (+51 additions, -52 deletions)

View changed files

📝 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php (+17 -12)
📝 lib/Doctrine/ORM/Persisters/EntityPersister.php (+2 -2)
📝 lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php (+10 -13)
📝 lib/Doctrine/ORM/Query/SqlWalker.php (+20 -23)
📝 tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php (+2 -2)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/910 **Author:** [@deeky666](https://github.com/deeky666) **Created:** 1/13/2014 **Status:** ✅ Merged **Merged:** 1/31/2014 **Merged by:** [@beberlei](https://github.com/beberlei) **Base:** `master` ← **Head:** `DDC-2310` --- ### 📝 Commits (1) - [`b9ff877`](https://github.com/doctrine/orm/commit/b9ff877f149dc7c4d3339c773252be4c5d3fcb9d) fix SQL generation on table lock hint capable platforms ### 📊 Changes **5 files changed** (+51 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/Persisters/BasicEntityPersister.php` (+17 -12) 📝 `lib/Doctrine/ORM/Persisters/EntityPersister.php` (+2 -2) 📝 `lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php` (+10 -13) 📝 `lib/Doctrine/ORM/Query/SqlWalker.php` (+20 -23) 📝 `tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php` (+2 -2) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:02:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#8887