Slick: create query conjunctions/disjunctions dynamically

后端 未结 4 743
难免孤独
难免孤独 2020-12-28 11:04

I\'m trying to create a typesafe dynamic DSL for a Slick table but not sure how to achieve this.

Users can post filters to the server by sending filters in form/json

4条回答
  •  梦毁少年i
    2020-12-28 11:19

    I was looking for the same thing, and came across this question - the accepted answer was a very heavy inspiration to what I eventually landed on. Details are here.

    The only comments I'd make about the accepted answer - TablePredicate[Item, T <: Table[Item]] can just be simplified to TablePredicate[T <: Table[_]] because Item is never used (at least in the sample). LiteralColumn(1) === LiteralColumn(1) can also just be LiteralColumn(Some(true)) (makes the generated queries slightly less awkward) - I'm pretty sure with a little more work, these could be eliminated entirely.

提交回复
热议问题