在光滑(1.0)中,在表格上执行.where()
,.filter()
和.withFilter()
之间有什么区别?
在API中,他们有类似的签名,但不清楚它们有何区别:
def filter[T] (f: (E) ⇒ T)(implicit wt: CanBeQueryCondition[T]): Query[E, U]
def where[T <: Column[_]](f: (E) ⇒ T)(implicit arg0: CanBeQueryCondition[T]): Query[E, U]
def withFilter[T] (f: (E) ⇒ T)(implicit arg0: CanBeQueryCondition[T]): Query[E, U]
答案 0 :(得分:9)
根据source,所有这些方法都是相同的:
def withFilter[T : CanBeQueryCondition](f: E => T) = filter(f)
def where[T <: Column[_] : CanBeQueryCondition](f: E => T) = filter(f)
过滤器是在scala中过滤集合的常用方法。集合中有filter
方法,Option
,Future
,Try
等等。
for comprehensions
。理解中的if
声明已转换为withFilter
的调用。
我猜其中与SQL
where
声明类似。