From 4041018c47d547466a6699e6c1855a1cd1e3e17e Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sun, 11 Apr 2021 12:55:23 +0200 Subject: [PATCH] Reduce not expressions Fixes queries containing macros inside a "not". --- .../src/main/scala/docspell/query/internal/ExprUtil.scala | 2 +- .../docspell/store/generator/ItemQueryGeneratorTest.scala | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/query/shared/src/main/scala/docspell/query/internal/ExprUtil.scala b/modules/query/shared/src/main/scala/docspell/query/internal/ExprUtil.scala index 8f7b6c2c..ebe42e52 100644 --- a/modules/query/shared/src/main/scala/docspell/query/internal/ExprUtil.scala +++ b/modules/query/shared/src/main/scala/docspell/query/internal/ExprUtil.scala @@ -31,7 +31,7 @@ object ExprUtil { case DirectionExpr(flag) => DirectionExpr(!flag) case _ => - expr + NotExpr(reduce(inner)) } case m: MacroExpr => diff --git a/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala b/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala index 2182cf56..25ee0af0 100644 --- a/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala +++ b/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala @@ -43,4 +43,11 @@ class ItemQueryGeneratorTest extends FunSuite { assertEquals(cond, expect) } + test("!conc:*") { + val q = ItemQueryParser.parseUnsafe("!conc:*") + val cond = ItemQueryGenerator(now, tables, Ident.unsafe("coll"))(q) + val expect = not(tables.concPers.name.like("%") || tables.concEquip.name.like("%")) + assertEquals(cond, expect) + } + }