Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
sio4 merged 1 commit intomainfrom
fix-mysql-delete-with-where-in
Sep 24, 2022
Merged

fixed delete + where in issue on mysql (#699)#784
sio4 merged 1 commit intomainfrom
fix-mysql-delete-with-where-in

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
@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