zio / zio-quill

Compile-time Language Integrated Queries for Scala

Home Page:https://zio.dev/zio-quill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing encoding for `Short` and `Byte` in Cassandra contexts

mosyp opened this issue · comments

Version: 2.3.2
Module: quill-cassandra

Expected behavior

Provide encoders/decoders form Short and Byte

Actual behavior

Encoders/decoders are missing

Workaround

implicit val byteDecoder: Decoder[Byte] = decoder(_.getByte)
implicit val byteEncoder: Encoder[Byte] = encoder(_.setByte)

implicit val shortDecoder: Decoder[Short] = decoder(_.getShort)
implicit val shortEncoder: Encoder[Short] = encoder(_.setShort)

@getquill/maintainers

@mentegy what's the exact type of Decoder?

@blueberrynotblue Encoding is driver dependent, however in general those are functions to extract value from a result row (Decoder) and prepare value to prepare row (Encoder). Example in http://getquill.io/#extending-quill-custom-encoding-raw-encoding

@mentegy how do I write codec for Map[x,y] , I think the most confusing part is which types got support from quill and which needs codec.

@blueberrynotblue one more note, quill itself does not provide any codec for cassandra. We have our own layers called Encoder/Decoder and provide mapping for common types

@mentegy thx a lot!!

@mentegy hi,
com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [tinyint <-> java.lang.Short] didn't dispear. I tried raw coding and your solution above.

CodecNotFoundException found in casssandra types of [tinyint,date] so far.

In datastax library, there're these codec code, which is weird.

My enviroment:
cassandra 3.11.1
dependency: "io.getquill" %% "quill-cassandra" % "2.3.2"
scala:2.12.2

@blueberrynotblue Could you prepare reproducible and dedicated code for me, so I can take a look?

This would also be very useful to do for quill-jdbc since most SQL dialects have a tinyint. Also an encoding for Char would be very useful for varchar(1) columns.