Skip to content

Conversation

lcobucci
Copy link
Member

@lcobucci lcobucci commented Feb 18, 2018

As mentioned in #7053, this fixes the issue without breaking other tests.

}

$aliasIdentificationVariable = $this->AliasIdentificationVariable();
try {
Copy link
Member Author

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) {
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Works as-is

Copy link
Member Author

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 😂

@lcobucci
Copy link
Member Author

lcobucci commented Feb 18, 2018

@Ocramius @guilhermeblanco I was checking JPA 2.2 specs and maybe we should rather update the grammar for bulk deletes:

delete_statement ::= delete_clause [where_clause]
delete_clause ::= DELETE FROM entity_name [[AS] identification_variable]

Source: http://download.oracle.com/otndocs/jcp/persistence-2_2-mrel-spec/index.html (4.10 Bulk Update and Delete Operations)

}

$aliasIdentificationVariable = $this->AliasIdentificationVariable();
try {
Copy link
Contributor

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?

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 indeed, updating

Copy link
Member Author

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

carnage and others added 3 commits February 19, 2018 00:50
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`.
@lcobucci lcobucci force-pushed the fix-delete-bc-break branch from 096ce9f to fc943b7 Compare February 18, 2018 23:53
Copy link
Member

@Ocramius Ocramius left a 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) {
Copy link
Member

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';
Copy link
Member

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)

Copy link
Member Author

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?

Copy link
Member

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 👍

Copy link
Member Author

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
Copy link
Member

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

@lcobucci
Copy link
Member Author

@Ocramius and what's your opinion regarding changing the grammar?

@Ocramius
Copy link
Member

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.

@Ocramius Ocramius merged commit 1f82a20 into doctrine:2.6 Feb 19, 2018
@Ocramius
Copy link
Member

This has been forward-ported to master in 92445d0

Ocramius added a commit that referenced this pull request Feb 19, 2018
@lcobucci lcobucci deleted the fix-delete-bc-break branch February 19, 2018 10:52
maglnet pushed a commit to maglnet/doctrine2 that referenced this pull request Oct 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants