Salat v1.10.0 is a major release with some non-backwards compatible changes. It includes support for Casbah 2.8.2 / Mongo 3.0, various bug fixes, and better error messages for common serialization issues.
Most notably, the package has changed from com.novus.salat._
to salat._
Change Log
Major Changes
- #177 Change package from
com.novus.salat._
to justsalat._
Dependency Upgrades
- #145 Upgrade to Casbah 2.8.2 (@danslapman, @sief, @noahlz)
Features
- #115 Add
findAndModify
toBaseDAOMethods
. (@noahlz) - #143 Log more details with deserialization errors. (@noahlz, @slorber)
- #148 Fail faster during deserialization when narrowing type conversion would lose information. (@noahlz)
- #155 Improve support for binary data such as
Seq[Byte]
in case classes. (@glorat) - #171 Support
Map[String, Any]
,List[Any], Option[Any]
(@dieu, @noahlz) - #173 Improve error message for
Map[String, List[_]
de-serialization error. (@noahlz)
Compatibility
If you create a
SalatDAO
using a collection created from aMongoClient
, its methods may throw aSalatDAOError
having aMongoException
root cause.SalatDAOError
now extendsRuntimeException
instead ofjava.lang.Error
, and the constructor signature has changed accordingly.A
SalatDAO
created using aMongoCollection
from aMongoConnection
will attempt attempt to detect errors from theWriteResult
. However, this is not guaranteed to work (from the Mongo 3.x upgrade notes: "[getLastError] does not work reliably in the 2.x series and there is no way to make it work reliably" - http://mongodb.github.io/mongo-java-driver/3.0/whats-new/upgrading/). Be sure to useMongoClient
.Introduced a new subclass of
Error
:SalatGlitch
. This class specifically identifies errors that occur during serialization / deserialization. Note that there are still many points in code that throw RuntimeException (viasys.error
) - overhaul/normalization of Salat's errors remains an outstanding TODO.Previously case classes with fields containing Integer data, such as
Int
,Option[Int]
,Seq[Int]
, orMap[String, Int]
, would experience narrowing with information loss, or aClassCastException
when attempting to unbox the field value, if the deserialized JSON or Mongo document contained aDouble
value in the field. In addition, a JSON document with goofy contents like{"foo":"nine-point-oh"}
would return aNone
, swallowing theNumberFormatException
(if thefoo
field of the case class was anOption[Double]
or somesuch). With this version, deserialization will fail-fast when the JSON document has a field with a String in an invalid number format, or a Double literal that cannot be narrowed without loss of information (such as9.0001
). However, as JavaScript only has a float numeric type, Doubles that can be narrowed without information loss will be converted to an Int (9.0
converted to9
, for example).
Please report any issues to https://github.com/salat/salat/issues
Thanks!