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

Derivation strategies #542

Closed
wedens opened this issue Jul 4, 2017 · 8 comments
Closed

Derivation strategies #542

wedens opened this issue Jul 4, 2017 · 8 comments
Labels
Feature Request Requests for new functionality
Milestone

Comments

@wedens
Copy link
Contributor

wedens commented Jul 4, 2017

It would be useful to be able to choose how to use (or not to use) derivation:

  • auto derivation (currently by default)
  • semi-auto derivation (implicit val userComposite: Composite[User] = deriveComposite[User])
  • no derivation (custom instances)

For example: circe provides such choice for codec derivation.

Drawbacks of auto-derivation as the only choice:

  • It's slow (at least compile-time). Instances are derived at call site.
  • Every case class is assumed to be correspondable to a row in result set. It is not always the case and you may want to explicitly say "this type corresponds to a row" by having Composite instance.
@tpolecat tpolecat added this to the Backlog milestone Jul 30, 2017
@tpolecat tpolecat modified the milestones: Backlog, 0.6.x Apr 11, 2018
@lorandszakacs
Copy link
Member

I'd honestly pick this up, but my shapeless-foo isn't quite the best. But maybe might be able to spin something up.

I'd really like to have this, as I've foot-gunned myself many times by automatic derivation basically in every library that supports it, and have moved completely to using some-kind of semi-auto derivation.

@tpolecat
Copy link
Member

tpolecat commented Oct 3, 2019

I will have a look at this. It may not be too bad.

@hamnis
Copy link
Contributor

hamnis commented Jan 28, 2022

Would this be possible to revisit? Scala 3 has wonderful semiauto capabilities thanks to the derives keyword.

@Daenyth Daenyth added the Feature Request Requests for new functionality label Mar 25, 2022
@jatcwang jatcwang modified the milestones: 0.6.x, 1.0 Aug 10, 2022
@jatcwang
Copy link
Collaborator

This can probably be done by moving the auto derivation implicit defs to a separate import, then use scalafix to add that import for all existing doobie codebases. And then going forward all auto-derivation will require the explicit import much like io.circe.generic.auto._

@jatcwang
Copy link
Collaborator

I think #1738 is the right way to go. Will resurrect it.

@oyvindberg
Copy link
Contributor

That would be wonderful @jatcwang . Remember there is Text as well :)

@jatcwang
Copy link
Collaborator

jatcwang commented Jan 7, 2024

#1967 (resurrected from #1738) has been merged but we still need #1970 to not inconvenient users

Created #1976 for optimizing compile time.

@jatcwang
Copy link
Collaborator

jatcwang commented Sep 1, 2024

#1970 is merged. Closing

@jatcwang jatcwang closed this as completed Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Requests for new functionality
Projects
None yet
Development

No branches or pull requests

7 participants