CodeLionX / actordb

Actor Database System Framework using Akka
MIT License
0 stars 2 forks source link

Use Set instead of Seq for columns in Records and Relations #29

Closed srfc closed 6 years ago

srfc commented 6 years ago

Fixes #16

Proposed Changes

srfc commented 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 Relations columns into project:

myRecord.project(myRelation.columns)

This would lend itself to the Don't overload paradigm of Scala - see discussion on s/o.

srfc commented 6 years ago

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 Relations columns is so easy.

CodeLionX commented 6 years ago

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))