Slick where / filter / withFilter

In slick (1.0), what is the difference between executing .where() , .filter() and .withFilter() in a table?

They have a similar signature in the API , but it is not clear how they differ:

 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] 
+7
source share
1 answer

According to source, all of these methods are the same:

 def withFilter[T : CanBeQueryCondition](f: E => T) = filter(f) def where[T <: Column[_] : CanBeQueryCondition](f: E => T) = filter(f) 

filter is a general method of filtering collections in scala. There is a filter , Option , Future , Try , etc. method in collections.

withFilter exists for comprehensions . if expression for concepts translates into a call to withFilter .

I think where is added by analogy with the SQL where SQL .

+9
source

All Articles