You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During test runs I namespace all Redis operations under "test:* using the redis-namespace Gem. Let's check to see if it works if I configure only: ["test*"]:
Hi @niborg, I appreciate your efforts on this PR. After reviewing your changes, I had a thought about another approach that might also work well, and in some ways, it might improve upon the solution. It's just an idea, and I'd love to hear your thoughts on it. Let me know what you think!
Hi @satoruk that solution is fine, and I support it if you want to proceed with it (it is less code, which is attractive!). However, it is worth considering the my rationale as set forth in the PR:
Resolves bug that would wipe the entire Redis db when an only specification is provided but there are no matching keys in the db. This is achieved by defaulting the only and except arguments to be nil, which signals that they have not been set whereas implementation before was ambiguous. And if only has not been set, then the code knows to use all Redis keys.
Your solution leaves a bit of an awkward API. For example, DatabaseCleaner::Redis::Deletion.new(only: []) suggests by its syntax that it will not delete any keys, but it actually deletes every key. I admit this usage is "weird" and probably would only occur by accident or by someone unfamiliar with database cleaning and this library, but the end result (deleting every key in redis) is pretty unfortunate that it is nice to avoid.
But in short, please go with whatever solution you prefer. I'd happily use either approach.
Activity
niborg commentedon Oct 7, 2022
We are also running into this issue.
jherdman commentedon Oct 7, 2022
@niborg the solution I've adopted is to avoid this gem entirely for Redis. The solution I've settled on for my use case as follows:
my-project:test:foo— I'm using https://rubygems.org/gems/redis-namespace)The entire solution is maybe 10-15 lines of code including configuration.
niborg commentedon Oct 9, 2022
@jherdman I added a PR in #15 that should fix the issue.
satoruk commentedon Jul 6, 2023
Hi @niborg, I appreciate your efforts on this PR. After reviewing your changes, I had a thought about another approach that might also work well, and in some ways, it might improve upon the solution. It's just an idea, and I'd love to hear your thoughts on it. Let me know what you think!
niborg commentedon Jul 6, 2023
Hi @satoruk that solution is fine, and I support it if you want to proceed with it (it is less code, which is attractive!). However, it is worth considering the my rationale as set forth in the PR:
Your solution leaves a bit of an awkward API. For example,
DatabaseCleaner::Redis::Deletion.new(only: [])suggests by its syntax that it will not delete any keys, but it actually deletes every key. I admit this usage is "weird" and probably would only occur by accident or by someone unfamiliar with database cleaning and this library, but the end result (deleting every key in redis) is pretty unfortunate that it is nice to avoid.But in short, please go with whatever solution you prefer. I'd happily use either approach.