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

There is no instance of Composite[List[A]] where A is a case class #691

Closed
asoltysik opened this issue Mar 1, 2018 · 2 comments
Closed

Comments

@asoltysik
Copy link

Doobie version: 0.5.0

import doobie._
import doobie.implicits._
import doobie.postgres.implicits._

case class Foo(a: Int)

Composite[List[Foo]]

Errors:

Could not find or construct Composite[List[Foo]].

  If List[Foo] is a simple type (or option thereof) that maps to a single column, you're
  probably missing a Meta instance. If List[Foo] is a product type (typically a case class,
  tuple, or HList) then probably one of its component types is missing a Composite instance. You can
  usually diagnose this by evaluating Composite[Foo] for each element Foo of the product type in
  question. See the FAQ in the Book of Doobie for more hints.

not enough arguments for method apply: (implicit A: doobie.util.composite.Composite[List[Foo]])doobie.util.composite.Composite[List[Foo]] in object Composite.
Unspecified value parameter A.
@wedens
Copy link
Contributor

wedens commented Mar 2, 2018

Which column type do you want to map to List?

You can probably do that for arrays. There are instances for postgres arrays of some primitive types (int4, bit and some others). In this case you can probably do val x: Meta[List[Foo]] = Meta[Array[Int]].xmap(_.toList.map(Foo(_)), _.toArray.map(_.a)).

@tpolecat
Copy link
Member

Given Meta[List[A]] and Generic[B] { type Repr = A :: HNil } we can derive Meta[List[B]] but it's marginal enough that I don't think I want to add the derivation implicitly. I think the answer is xmap, at least for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants