Actually after implementing it, I found that @cvogt had implemented the same method. 
https://github.com/slick/slick/blob/master/src/main/scala/scala/slick/jdbc/meta/CodeGen.scala#L37
Which one you prefer?