-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor CRUD::delete method to support advanced DELETE queries
#25
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
Conversation
… support advanced DELETE queries
defunctl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks a lot @shvlv !
I stopped commenting, but I'd like to see the following:
- Asserting the posts you created exist before they are deleted.
- Rather than assertNotNull, assert the type or an actual value.
|
@defunctl I've updated the test approach. |
@shvlv I was suggesting 2.0.0 because this changes the underlying functionality of a used method, but is also a bug fix. Are there no scenarios you can think of where someone is unintentionally relying on existing functionality and this update could break things for them, even though we're correcting the logic? |
For the current functionality, the only way it works as expected is to use only a simple DB::table('posts')
->where('post_type', 'delete_like_test')
->delete();If someone used something different, like |
That is my exact worry. That they even wrote tests for those buggy results, so it's really just a question of do we want to potentially release that type of issue right now, or when they move to 2.0.0 which is more expected with a major release that things could "break" |
defunctl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, your call on the release version, I personally think 2.0.0 so there aren't as many surprises, but I'll leave that up to you.
@borkweb may still want to have a look though :)
borkweb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this change and the code looks great, @shvlv. The likelihood that this will cause problems with current uses out in the wild is incredibly low due to the nature of how limited the delete() call was.
I'm ok with 1.2 and accept that there may be annoying edge case bugs that'll creep up due to bad implementations elsewhere.
|
@dpanta94 has put some good work on this should be aware of the changes. |
The current implementation relies on
wpdb::deletethat supports the simplewhere x = yconditions only. It's not only incomplete but also dangerous becauseWhere::$comparisonOperatorandWhere::$logicalOperatorare just ignored, so the result is unpredictable. The following change provides a way to use existing QueryBuilder functionality to generateDELETESQL. The documentation describes some restrictions.Additionally, I updated
actions/cachetov4to make CI tests run.