ScalaQuery for different Scala versions
July 22nd, 2009 | In Scala, ScalaQueryI have just created a new scala-2.7 branch for ScalaQuery. My original plan was to target only Scala 2.8 but since I’ve made lots of progress during the last few weeks and I’ve seen increased interest in ScalaQuery, I tried to build it with 2.7.5.
I had to change the semantics of SimpleFunction and SimpleBinaryOperator for 2.7 but I prefer the new version anyway, so it went into the main line. The code on the scala-2.7 branch is currently identical to the master branch, except for the test classes which are different in two regards:
- Although the Scala Language Specification mandates that the part left to the “
<-” in a for comprehension is a pattern, the wildcard pattern “_” does not work in 2.7. I have changed it to a dummy variable named “__“. - The type inferencer in 2.7 cannot infer the correct type for the implicit
OptionMapperobjects.OptionMapper[_,_,_,_]has four type parameters, the last one being used for the return type of functions which use the mapper, so it is not yet known when looking for an implicit mapper and gets inferred asNothing. Scala 2.8 apparently knows that this type parameter is undetermined, finds the single matching implicit object for the other three parameters and then fills in the fourth. The type-correct interoperability of option and non-option types in ScalaQuery relies heavily on the improved type inferencer and I don’t see any way of making it work nicely with 2.7. The work-around is to add type annotations to the boolean operators, e.g.a && bmight becomea.&&[Boolean,Option[Boolean]](b). Yuck!
I’m still focused on Scala 2.8 as a target platform and will probably not spend much time integrating new features into the scala-2.7 branch but contributions are always welcome.
July 26th, 2010 at 12:19 pm
without proper documentation, this is pretty much useless for most. Could you write proper documentation for this library (e.g., connecting to DB, creating table, inserting, querying, etc)?
July 26th, 2010 at 12:55 pm
Documentation is a work in progress. You can find it in the wiki: http://wiki.github.com/szeiger/scala-query/