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

Quill integration #163

Closed
daniel-shuy opened this issue Feb 1, 2018 · 1 comment
Closed

Quill integration #163

daniel-shuy opened this issue Feb 1, 2018 · 1 comment

Comments

@daniel-shuy
Copy link
Contributor

daniel-shuy commented Feb 1, 2018

I have a suggestion to add a trait to automatically encode/decode EnumEntrys as Strings, using their entryName, when querying/inserting from/into a Database using Quill.

This is my current implementation:

import enumeratum.{Enum, EnumEntry}
import io.getquill.MappedEncoding

trait QuillEnum[A <: EnumEntry] {
  this: Enum[A] =>

  implicit lazy val enumEncoder: MappedEncoding[A, String] = MappedEncoding(_.entryName)

  implicit lazy val enumDecoder: MappedEncoding[String, A] = MappedEncoding(withName)
}
@lloydmeta
Copy link
Owner

Sounds like a good idea :) A PR for adding said integration is welcome !

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

2 participants