Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDC-2310] Fix evaluation of NOLOCK table hint on SQL Server #508

Merged
merged 1 commit into from
Jan 14, 2014

Conversation

deeky666
Copy link
Member

This PR is complementary to doctrine/orm#910.
ORM passes null to AbstractPlatform::appendLockHint() as $lockMode which should not evaluated to LockMode::NONE unless 0 is explictly given. Otherwise ORM appends WITH (NOLOCK) to all queries even though, no query lock hint is set.

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-783

We use Jira to track the state of pull requests and the versions they got
included in.

@@ -1347,14 +1347,14 @@ public function rollbackSavePoint($savepoint)
*/
public function appendLockHint($fromClause, $lockMode)
{
switch ($lockMode) {
case LockMode::NONE:
switch (true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to if (...) { return ...; } blocks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I will do.

@Ocramius
Copy link
Member

@deeky666 I'd say the ORM is wrong here, since the docblock for appendLockHint requires an integer to be passed in. Probably action to be taken only on ORM?

@deeky666
Copy link
Member Author

@Ocramius I don't know if action has to be taken in ORM. At least the current implementation here is wrong because null is not a valid input parameter and should not be considered as explicit NOLOCK.
The question is what to do about invalid input here? Throw exception? This is not in the DocBlock, either =/
In SQLAnywherePlatform::appendLockHint() I threw an exception for unknown lock modes, but that failes big time in ORM, too.

@Ocramius
Copy link
Member

@deeky666 changing the docblock to allow integer|null is also acceptable and better than introducing a BC that requires changes in ORM.

Introducing the exception can be simply if ( ! is_in($lockMode)) { throw ...; }. A bit stupid, but helps identifying where the ORM is doing it wrong immediately. I wouldn't go down this path though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants