essential-slick icon indicating copy to clipboard operation
essential-slick copied to clipboard

Explain ConstColumn

Open d6y opened this issue 9 years ago • 1 comments

When should I use a ConstColumn and when a Rep?

E.g., when compiling a paged query, the drop needs to be a ConstColumn. If it's a Rep the error is drop cannot be applied to aRep[Long]`.

def paged(name: Rep[String], offset: ConstColumn[Long], limit: ConstColumn[Long]) =
    this.filter(_.name === name).drop(offset).take(limit)

d6y avatar Apr 12 '16 15:04 d6y

ScalaDoc for ConstColumn:

A scalar value that is known at the client side at the time a query is executed. This is either a constant value (LiteralColumn) or a scalar parameter.

The simple answer is that take (and drop) are only defined in terms of Int, Long and ConstColumn[Long]. And I can use ConstColumn[String] for the name of that paged method.

However, I feel I'm missing something deeper here. We don't seem to say what Rep[T] is.

d6y avatar Apr 12 '16 15:04 d6y