-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Delete SQL statement is wrong when using alias MySQL #4448
Labels
Comments
A test for |
It looks like the platforms have the following syntax: Additional alias In front of the FROM statement:
Behind the table name:
No alias / found no info:
|
simonberger
pushed a commit
to simonberger/dbal
that referenced
this issue
Dec 20, 2020
simonberger
added a commit
to simonberger/dbal
that referenced
this issue
Dec 20, 2020
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug Report
Invalid forming delete query when I use alias for table. Query produces a syntax error.
My
MySQL
version is5.7.25
.Summary
I'm using the delete like described in example
https://github.com/doctrine/dbal/blob/79cba0bc0e653005fc9ab5a23624828a803f41fb/lib/Doctrine/DBAL/Query/QueryBuilder.php#L545
This creates a query like this:
DELETE FROM users_groups ug WHERE ug.groupId = 1
that produces an MySQL errorERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ug WHERE ug.groupId = 1' at line 1
I do not know if this is a specific MySQL issue or for some MySQL versions, my current MySQL version is 5.7.25.
I've searched MySQL error related answers and i found this https://stackoverflow.com/a/26935749/2624626
For me
DELETE ug FROM users_groups ug WHERE ug.groupId = 1
worked as expected and without errors.Current behaviour
How to reproduce
CREATE TABLE test_delete (userId int, groupId int);
INSERT INTO test_delete (userId, groupId) VALUES (1,1), (1,2), (1,3), (2,1), (2,3);
DELETE FROM test_delete td WHERE td.groupId = 1;
https://www.db-fiddle.com/f/uPFmoWKGyQngD97AVMBV8Y/1
DELETE td FROM test_delete td WHERE td.groupId = 1;
$qb->execute();
Expected behaviour
The text was updated successfully, but these errors were encountered: