Closed srfc closed 6 years ago
Should we maybe get rid of Record.project(r: Relation)
? Because we can just as well use the default signature method by passing in a Relation
s columns into project
:
myRecord.project(myRelation.columns)
This would lend itself to the Don't overload paradigm of Scala - see discussion on s/o.
I removed the overload in the last commit. We can rollback that commit if the explicit type parameters don't bother us or add the overload back with a new name, e.g. projectRelation
.
I am fine with just leaving it as is now because apply project
it to a Relation
s columns is so easy.
one way to get rid of explicit type annotation for column definition sets is providing a implicit type cast for it:
import scala.language.implicitConversions
implicit def columnDefSet2UntypedSet[T](set: Set[ColumnDef[T]]): Set[UntypedColumnDef] =
set.asInstanceOf[Set[UntypedColumnDef]]
val result = User.project(Set(User.colFirstname, User.colLastname))
but where do we put it? I could imagine doing it like that:
// >>> ColumnDef.scala
import scala.language.implicitConversions
object ColumnDef {
...
implicit def columnDefSet2UntypedSet... // like above
}
...
}
// >>> TestApplication.scala
val result = User.project(Set(User.colFirstname, User.colLastname))
Fixes #16
Proposed Changes
ColumnDef
's instead of sequences since ordering should not matter w.r.t. columns or attribute fieldsRecord
's andRelation
's