-
Notifications
You must be signed in to change notification settings - Fork 21
EntityActions.idLens requires Option[Id] #74
Comments
Hi @taitruong Indeed, this could be a nice improvement. Actually, we I think we can even make the Lens typed as: By the way, since Id is a type member of Entity, it should also be possible to type it as Lens[Entity] Would you mind to experiment with that and send a pull request? I won't have time to try it myself in the coming days |
Hi Renato, I can do this. Unfortunately I am having problems integrating your project into mine as a sub project. I have already spent some hours and have error with multi projects using build.sbt. The error I get is this: Waiting for lock on /home/ttruong/.sbt/boot/sbt.boot.lock to be available... my build.sbt looks like this: name := "bi-data-generator" val commonSettings = Seq( lazy val activeSlick = project.in(file("active-slick")).settings(commonSettings:_*) libraryDependencies ++= Seq( "org.postgresql" % "postgresql" % "9.4-1204-jdbc41", "ch.qos.logback" % "logback-classic" % "1.1.3", "org.scalatest" %% "scalatest" % "2.2.4" % "test", //Gaussian libraries slick <<= slickCodeGenTask sourceGenerators in Compile <+= slickCodeGenTask lazy val slick = TaskKeySeq[File] Cheers, Tai |
Hi @taitruong, Sorry for my late reply. I was abroad and not having much time to sit in front of my computer. I never tried to include active-slick as a submodule. It's possible that our sbt is configured in a way that make it difficult (or impossible) to include it as a submodule. I suggest you to check out active-slick and build and publish it locally to your ivy repo. Please, let me know your findings. |
First of all: great api! I've spent half day implementing my own generic DAO but then I found yours :).
I have a question on your definition of EntityActions.idLens as defined like this in EntityActions:
def idLens: Lens[Entity, Option[Id]]
Wouldn't it be better to have it rather than this below (without Option)?
def idLens: Lens[Entity, Id]
Looking at your documentation on http://www.strongtyped.io/active-slick/ you use the Coffee example where id is optional. But I think this depends and should not be limited by your API. In your example you have this:
object CoffeeRepo extends EntityActions with H2ProfileProvider {
...
type Id = Int //
...
val idLens = lens { coffee: Coffee => coffee.id } //
{ (coffee, id) => coffee.copy(id = id) }
...
In my case all my IDs are mandatory and not optional. Now I have to override idLens by this:
val idLens = lens { entity: Entity => Option(entity.id )} //getter function
{ (entity, id) => entity.copy(id = id.get)} //setter function
Thanks, Tai
The text was updated successfully, but these errors were encountered: