File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
main/scala/com/sfxcode/nosql/mongo/bson
test/scala/com/sfxcode/nosql/mongo/converter Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 11package com .sfxcode .nosql .mongo .bson
22
33import java .math .BigInteger
4- import java .time .{ LocalDate , LocalDateTime , ZoneId }
4+ import java .time .{LocalDate , LocalDateTime , ZoneId }
55import java .util .Date
66
77import org .mongodb .scala .Document
@@ -28,6 +28,7 @@ object BsonConverter {
2828 converterPlugin.toBson(v)
2929 case b : Boolean => BsonBoolean (b)
3030 case s : String => BsonString (s)
31+ case c : Char => BsonString (c.toString)
3132 case bytes : Array [Byte ] => BsonBinary (bytes)
3233 case r : Regex => BsonRegularExpression (r)
3334 case d : Date => BsonDateTime (d)
Original file line number Diff line number Diff line change 11package com .sfxcode .nosql .mongo .converter
22
33import com .sfxcode .nosql .mongo .bson .BsonConverter
4- import org .mongodb .scala .bson ._
4+ import org .mongodb .scala .bson .{ ObjectId , _ }
55import org .specs2 .mutable .Specification
6-
76/**
87 * Created by tom on 22.01.17.
98 */
@@ -27,6 +26,13 @@ class BsonConverterSpec extends Specification {
2726 BsonConverter .toBson(BigInt (10 )) must be equalTo BsonInt64 (10 )
2827 BsonConverter .toBson(java.math.BigInteger .TEN ) must be equalTo BsonInt64 (10 )
2928
29+ BsonConverter .toBson(Some (5 )) must be equalTo BsonInt32 (5 )
30+
31+ BsonConverter .toBson(Some (new ObjectId (" 5b61455932ac3f0015ae2e7e" ))) must be equalTo BsonObjectId (" 5b61455932ac3f0015ae2e7e" )
32+
33+ BsonConverter .toBson(None ) must be equalTo BsonNull ()
34+
35+ BsonConverter .toBson('M' ) must be equalTo BsonString (" M" )
3036 }
3137
3238 " convert values from BSON" in {
You can’t perform that action at this time.
0 commit comments