From 623a61dbb61dd10a4624469fc6027201eb25c2a7 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sun, 17 Jan 2021 20:10:00 +0100 Subject: [PATCH] Introduce a lowerEq operator to the query builder --- modules/store/src/main/scala/docspell/store/qb/DSL.scala | 3 +++ .../store/src/main/scala/docspell/store/qb/Operator.scala | 1 + .../scala/docspell/store/qb/impl/ConditionBuilder.scala | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/modules/store/src/main/scala/docspell/store/qb/DSL.scala b/modules/store/src/main/scala/docspell/store/qb/DSL.scala index ce28d56e..db80e20b 100644 --- a/modules/store/src/main/scala/docspell/store/qb/DSL.scala +++ b/modules/store/src/main/scala/docspell/store/qb/DSL.scala @@ -164,6 +164,9 @@ trait DSL extends DoobieMeta { def ===(value: A)(implicit P: Put[A]): Condition = Condition.CompareVal(col, Operator.Eq, value) + def lowerEq(value: A)(implicit P: Put[A]): Condition = + Condition.CompareVal(col, Operator.LowerEq, value) + def ====(value: String): Condition = Condition.CompareVal(col.asInstanceOf[Column[String]], Operator.Eq, value) diff --git a/modules/store/src/main/scala/docspell/store/qb/Operator.scala b/modules/store/src/main/scala/docspell/store/qb/Operator.scala index 907c2593..47b436ef 100644 --- a/modules/store/src/main/scala/docspell/store/qb/Operator.scala +++ b/modules/store/src/main/scala/docspell/store/qb/Operator.scala @@ -5,6 +5,7 @@ sealed trait Operator object Operator { case object Eq extends Operator + case object LowerEq extends Operator case object Neq extends Operator case object Gt extends Operator case object Lt extends Operator diff --git a/modules/store/src/main/scala/docspell/store/qb/impl/ConditionBuilder.scala b/modules/store/src/main/scala/docspell/store/qb/impl/ConditionBuilder.scala index 3a4e4ede..f110bb92 100644 --- a/modules/store/src/main/scala/docspell/store/qb/impl/ConditionBuilder.scala +++ b/modules/store/src/main/scala/docspell/store/qb/impl/ConditionBuilder.scala @@ -69,6 +69,8 @@ object ConditionBuilder { val colFrag = op match { case Operator.LowerLike => lower(col) + case Operator.LowerEq => + lower(col) case _ => SelectExprBuilder.column(col) } @@ -80,6 +82,8 @@ object ConditionBuilder { val dbfFrag = op match { case Operator.LowerLike => lower(dbf) + case Operator.LowerEq => + lower(dbf) case _ => DBFunctionBuilder.build(dbf) } @@ -89,6 +93,8 @@ object ConditionBuilder { val (c1Frag, c2Frag) = op match { case Operator.LowerLike => (lower(c1), lower(c2)) + case Operator.LowerEq => + (lower(c1), lower(c2)) case _ => (SelectExprBuilder.column(c1), SelectExprBuilder.column(c2)) } @@ -131,6 +137,8 @@ object ConditionBuilder { op match { case Operator.Eq => fr" =" + case Operator.LowerEq => + fr" =" case Operator.Neq => fr" <>" case Operator.Gt =>