DB::delete() uses wpdb::delete() under the hood, which only supports the = comparison operator.
This can cause some seriously unexpected results, because the SQL is silently converted and doesn't warn the developer that they aren't executing their expected query.
Ideally, we would no longer use wpdb::delete() under the hood and instead build our own DELETE SQL. Temporary solutions could be some doc updates and finding a way to throw an exception if a developer tries to do this.
Delete query with comparison operator other than =:
DB::delete() uses wpdb::delete() under the hood, which only supports the
=
comparison operator.This can cause some seriously unexpected results, because the SQL is silently converted and doesn't warn the developer that they aren't executing their expected query.
Ideally, we would no longer use wpdb::delete() under the hood and instead build our own DELETE SQL. Temporary solutions could be some doc updates and finding a way to throw an exception if a developer tries to do this.
Delete query with comparison operator other than
=
:The expected SQL for the above query:
The actual SQL for the above query: