Skip to content

Finagle Postgres Int decoder throws when reading a value #1844

Description

@jonathan-ostrander

This template isn't a strict requirement to open issues, but please try to provide as much information as possible.

Version: 3.4.10
Module: quill-finagle-postgres
Database: Postgres (embedded through zonky)

Expected behavior

val client: PostgresClient
val ctx = new FinaglePostgresContext(SnakeCase, client)
import ctx._

case class Person(name: String, age: Int)
val p = Person("Bob", 25)

// Expected value is for this to be equal to `p`
Await.result(
  for {
    _ <- client.execute("CREATE TABLE person (name VARCHAR(100), age INT)")
    _ <- run(query[Person].insert(lift(p)))
    people <- run(query[Person])
  } yield people.head
)

Actual behavior

Throws:

java.lang.IllegalStateException: Cannot decode value None at index 0 to Int
  at io.getquill.util.Messages$.fail(Messages.scala:38)
  at io.getquill.context.finagle.postgres.FinaglePostgresDecoders.$anonfun$decoder$1(FinaglePostgresDecoders.scala:29)
  at io.getquill.context.finagle.postgres.FinaglePostgresDecoders.$anonfun$decoder$1$adapted(FinaglePostgresDecoders.scala:25)
  at io.getquill.context.finagle.postgres.FinaglePostgresDecoders$FinaglePostgresDecoder.apply(FinaglePostgresDecoders.scala:21)
  at $anon$1.$anonfun$extract$1(<console>:59)
  at com.twitter.util.Return.map(Try.scala:311)
  at com.twitter.util.Future.$anonfun$map$1(Future.scala:1910)
  at com.twitter.util.ConstFuture.transformTry(ConstFuture.scala:43)
  at com.twitter.util.Future.map(Future.scala:1910)
  at com.twitter.concurrent.AsyncStream.map(AsyncStream.scala:241)
  at com.twitter.finagle.postgres.PreparedStatement.$anonfun$selectToStream$1(PreparedStatement.scala:19)

Steps to reproduce the behavior

Here's a Scastie but for some reason it constantly times out. I got it to resolve the final Future in one run and it errored out with the same IllegalStateException that I get locally.

Edit: Scastie run with the error

Workaround

Currently, using a Short instead of an Int works fine.

@getquill/maintainers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions