Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add encoder/decoder for Byte #1143

Merged
merged 3 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ trait Decoders extends CollectionDecoders {
implicit val booleanDecoder: Decoder[Boolean] = decoder((index, row) => row.field[Boolean](row.fieldNames()(index)))
implicit val intDecoder: Decoder[Int] = decoder((index, row) => row.field[Int](row.fieldNames()(index)))
implicit val shortDecoder: Decoder[Short] = decoder((index, row) => row.field[Int](row.fieldNames()(index)).toShort)
implicit val byteDecoder: Decoder[Byte] = decoder((index, row) => row.field[Int](row.fieldNames()(index)).toByte)
implicit val longDecoder: Decoder[Long] = decoder((index, row) => {
if (row.fieldValues()(index).isInstanceOf[Int]) {
row.field[Int](row.fieldNames()(index)).toLong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ trait Encoders extends CollectionEncoders {
implicit val booleanEncoder: Encoder[Boolean] = encoder((index, value, row) => { row.insert(index, value); row })
implicit val intEncoder: Encoder[Int] = encoder((index, value, row) => { row.insert(index, value); row })
implicit val shortEncoder: Encoder[Short] = encoder((index, value, row) => { row.insert(index, value); row })
implicit val byteEncoder: Encoder[Byte] = encoder((index, value, row) => { row.insert(index, value); row })
implicit val longEncoder: Encoder[Long] = encoder((index, value, row) => { row.insert(index, value); row })
implicit val floatEncoder: Encoder[Float] = encoder((index, value, row) => { row.insert(index, value); row })
implicit val doubleEncoder: Encoder[Double] = encoder((index, value, row) => { row.insert(index, value); row })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class EncodingSpec extends Spec {
e.v7 mustEqual a.v7
e.v8.toList mustEqual a.v8.toList
e.v11.isInstanceOf[Date]
e.v13 mustEqual a.v13
e.o1 mustEqual a.o1
e.o2 mustEqual a.o2
e.o3 mustEqual a.o3
Expand All @@ -74,6 +75,7 @@ class EncodingSpec extends Spec {
e.o6 mustEqual a.o6
e.o7 mustEqual a.o7
e.o8.map(_.toList) mustEqual a.o8.map(_.toList)
e.o10 mustEqual a.o10

()
}
Expand All @@ -90,6 +92,7 @@ class EncodingSpec extends Spec {
v8: Array[Byte],
v11: Date,
v12: Short,
v13: Byte,
o1: Option[String],
o2: Option[BigDecimal],
o3: Option[Boolean],
Expand All @@ -98,7 +101,8 @@ class EncodingSpec extends Spec {
o6: Option[Float],
o7: Option[Double],
o8: Option[Array[Byte]],
o9: Option[Date]
o9: Option[Date],
o10: Option[Byte]
)

val insertValues =
Expand All @@ -115,6 +119,7 @@ class EncodingSpec extends Spec {
v8 = Array(1.toByte, 2.toByte),
v11 = new Date(31202000),
v12 = 1,
v13 = 8.toByte,
o1 = Some("s"),
o2 = Some(BigDecimal(1.1)),
o3 = Some(true),
Expand All @@ -123,7 +128,8 @@ class EncodingSpec extends Spec {
o6 = Some(34.4f),
o7 = Some(42.4d),
o8 = Some(Array(1.toByte, 2.toByte)),
o9 = Some(new Date(31200000))
o9 = Some(new Date(31200000)),
o10 = Some(8.toByte)
),
EncodingTestEntity(
id = 2,
Expand All @@ -137,6 +143,7 @@ class EncodingSpec extends Spec {
v8 = Array(),
v11 = new Date(0),
v12 = 2,
v13 = 7.toByte,
o1 = None,
o2 = None,
o3 = None,
Expand All @@ -145,7 +152,8 @@ class EncodingSpec extends Spec {
o6 = None,
o7 = None,
o8 = None,
o9 = None
o9 = None,
o10 = None
)
)
}