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

fixed delete + where in issue on mysql (#699) #784

Merged
merged 1 commit into from
Sep 24, 2022

Conversation

sio4
Copy link
Member

@sio4 sio4 commented Sep 24, 2022

Fixed Delete() + WHERE IN issue on MySQL for #699.

The direct cause was the implementation of Delete(). When the query could have WHERE IN, currently the query should be generated via SQLBuilder (specifically sqlx.In() in sqlBuilder.compile() to expand ? to match with the arguments.

The root cause is the SQL syntax of MySQL. MySQL 5.7 does not support table alias for the DELETE statement, so AS table_alias causes a syntax error. I guess the Delete() for MySQL has its own implementation for this reason. The syntax was changed in 8.0 so when 5.7 is fully EOSed, we can use the generic version here.

fixes #699

@sio4 sio4 added bug Something isn't working f: sql about SQL support labels Sep 24, 2022
@sio4 sio4 added this to the v6.0.7 milestone Sep 24, 2022
@sio4 sio4 self-assigned this Sep 24, 2022
dialect_mysql.go Show resolved Hide resolved
@sio4 sio4 merged commit 902a7d1 into main Sep 24, 2022
@sio4 sio4 deleted the fix-mysql-delete-with-where-in branch September 24, 2022 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working f: sql about SQL support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MySQL Delete doesn't work when combined with Where ... in (?)
1 participant