-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix BC-break on delete without alias DQL #7077
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
Conversation
lib/Doctrine/ORM/Query/Parser.php
Outdated
} | ||
|
||
$aliasIdentificationVariable = $this->AliasIdentificationVariable(); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should a have a comment here to explain the 💩 and specially mention that we should raise a deprecation notice in v2.7.0
if ($token < Lexer::T_IDENTIFIER) { | ||
$this->syntaxError($this->lexer->getLiteral($token)); | ||
} | ||
if ($lookaheadType === $token) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can drop this commit if you prefer, it was just to make things a bit more sane.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as-is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works indeed, it's just not so good as it could be... I can send another PR to make you happier 😂
@Ocramius @guilhermeblanco I was checking JPA 2.2 specs and maybe we should rather update the grammar for bulk deletes:
Source: http://download.oracle.com/otndocs/jcp/persistence-2_2-mrel-spec/index.html (4.10 Bulk Update and Delete Operations) |
lib/Doctrine/ORM/Query/Parser.php
Outdated
} | ||
|
||
$aliasIdentificationVariable = $this->AliasIdentificationVariable(); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use $this->lexer->isNextToken for this instead of trying to handle the exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed, updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carnage thanks... it was a way too gambiarra before HAHAHA
The `v2.5.x` series of the ORM allowed to have DELETE DQLs without using an alias, even though it didn't follow the grammar rules of the parser. We fixed that issue on `v2.6.0` however that was a BC-breaking change and lots of people were relying on this faulty behaviour. This workaround fixes the BC-break, without even trying to be elegant. In `v2.7.0.` we should raise a deprecation notice to notify people that we'll drop that "feature" in `v3.0`.
096ce9f
to
fc943b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another location to check is Doctrine\ORM\QueryBuilder#delete()
, which allows for an optional alias. We should probably raise a deprecation notice there too...
if ($token < Lexer::T_IDENTIFIER) { | ||
$this->syntaxError($this->lexer->getLiteral($token)); | ||
} | ||
if ($lookaheadType === $token) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as-is
$aliasIdentificationVariable = $this->AliasIdentificationVariable(); | ||
$aliasIdentificationVariable = $this->lexer->isNextToken(Lexer::T_IDENTIFIER) | ||
? $this->AliasIdentificationVariable() | ||
: 'alias_should_have_been_set'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should likely raise a deprecation notice here, to clarify that this isn't supported DQL (according to BNF)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we say that deprecation notices were going to be added in v2.7
only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me as long as you please create an issue tracking this specific deprecation 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I was going to do that anyway 😄
} | ||
} | ||
|
||
public function testSupportsDeleteWithoutWhereAndAlias() : void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an @group
to this
@Ocramius and what's your opinion regarding changing the grammar? |
Only after we move to https://github.com/hoaproject/Compiler Documenting grammar BC breaks becomes trivial after that. No changes before that, IMO. |
This has been forward-ported to |
…lt, so the test needs adaptation
As mentioned in #7053, this fixes the issue without breaking other tests.