Negated PREFIX filter operator generates an exception
Expected Behavior
When using a NotFilterExpression on a PrefixPredicate, it should return data that does not start with the specified text.
NotFilterExpression(PrefixPredicate(keyPath, listOf("foo")))
Current Behavior
An InvalidOperatorNegationException is raised when calling NotFilterExpression on a PrefixPredicate, since there is no negated value declared for the PREFIX operator.
Possible Solution
Creating a new NOT_PREFIX operator which returns the opposite of the PREFIX operator, and declaring it in the static code of the FilterTranslator class generates valid results.
Steps to Reproduce (for bugs)
- Create a SecurityCheck which returns a NotFilterExpression of a PrefixPredicate
- Assign this SecurityCheck to an entity
- Call this entity's endpoint.
Context
I need to enforce a filter to exclude all data starting with a specific prefix.
Your Environment
- Elide version used: 6.1.9-SNAPSHOT
- Environment name and version (Java 1.8.0_152): Java 11.0.12
- Operating System and version: Windows 10
- Link to your project: N/A
Seems like a reasonable request. If you have cycles and interest to submit a PR for this, I'm happy to review it.
Thanks, I'll be happy to take care of it, since I already have working local code; I just need to do a bit of cleanup and I'll submit a PR.
Any update @LamWizy ?
Yes, I have just resumed working on it; I've been interrupted with other things in the past weeks, but this is definitely something I want to get done.
Hi @aklish, I have submitted a PR for the fix.
I ran the code through IntelliJ's reformat/optimize import/scan with checkstyle options, which seem to have made some (unrelated) syntactic changes. Let me know if you would prefer to avoid these changes (I forced these options since my last PR failed the checkstyle scan, even though I believe I imported Elide's definition).