Question

I'm using the Slick generator to generate my tabble definitions based on my database and I would like to change a thing in the generated code. When it generates the classes it does not put my auto increment keys as Option[Int] = None in the case classes... Is there a way to do that? And maybe add an autoinc method in the table definition that returns the generated id like this for example:

def autoInc = id.? ~ name <> (User, User.unapply _) returning id
Was it helpful?

Solution

The code generator already supports this. You have to set autoIncLastAsOption = true.

new SourceCodeGenerator(model){
    override def Table = new Table(_){
        override def autoIncLastAsOption = true
    }
}

Also see http://slick.typesafe.com/doc/2.0.0/code-generation.html for more help with customizing the code generator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top