slick/slick — pull request #78 by patrick-premont (2012-12-12 18:56:54+00:00)
Title: ~ over MappedProjection

Thanks for the great work on slick.

I've explored the possibility of generalizing the ~ operator to also work on MappedProjections. I've added the following test case

slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/TupledMapTest.scala

In it you can see my motivation: the class IdTable is like a Table but take cares of adding an 'id' column and wrapping the result in a Id case class.

This allows inserting on **, a MappedProjection that does not include the id column, using a user type that is not wrapped by Id, while queries can return the user type wrapped by Id.

This involves two layers of MappedProjection, with an intervening ~. It offers an alternative strategy to the use of Option[Int] for the id field. You get two types (Triple and Id[Triple]), instead of a single type with an optional id. Having this type level distinction potentially enables more type safety.

Could you look at this and tell me whether it makes sense ? It compiles and does not break the test-suite, but there may issues I'm missing. I have not used it extensively either. If it makes sense, is that something you'd care to merge into slick ?

Thanks!

Patrick
Senior Software Developer - Tindr Solutions Inc.