elide icon indicating copy to clipboard operation
elide copied to clipboard

Negated PREFIX filter operator generates an exception

Open LamWizy opened this issue 3 years ago • 1 comments

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)

  1. Create a SecurityCheck which returns a NotFilterExpression of a PrefixPredicate
  2. Assign this SecurityCheck to an entity
  3. 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

LamWizy avatar Sep 21 '22 14:09 LamWizy

Seems like a reasonable request. If you have cycles and interest to submit a PR for this, I'm happy to review it.

aklish avatar Sep 22 '22 03:09 aklish

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.

LamWizy avatar Sep 23 '22 14:09 LamWizy

Any update @LamWizy ?

aklish avatar Oct 21 '22 17:10 aklish

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.

LamWizy avatar Oct 21 '22 18:10 LamWizy

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).

LamWizy avatar Oct 25 '22 17:10 LamWizy