-
Notifications
You must be signed in to change notification settings - Fork 26
Bumped Slick to version 3.6.1 and Play-slick to version 5.4.0 #111
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
base: master
Are you sure you want to change the base?
Changes from all commits
a378b7b
5e722df
be548c8
ea1d998
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package org.virtuslab.unicorn | ||
|
|
||
| import slick.jdbc.JdbcProfile | ||
|
|
||
| import scala.reflect.ClassTag | ||
|
|
||
| class IsomorphicColumnTypeConversion(implicit val profile: JdbcProfile) { | ||
| import profile._ | ||
| implicit def isomorphicType[A, B](implicit iso: Isomorphism[A, B], ct: ClassTag[A], jt: BaseColumnType[B]): BaseColumnType[A] = | ||
| MappedColumnType.base[A, B](iso.map, iso.comap) | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||
| package org.virtuslab.unicorn | ||||||
|
|
||||||
| import scala.language.experimental.macros | ||||||
| import scala.reflect.macros.blackbox.Context | ||||||
| import scala.util.control.NonFatal | ||||||
|
|
||||||
| /** An isomorphism between two types that can be used for mapped column types. */ | ||||||
| class Isomorphism[A, B](val map: A => B, val comap: B => A) | ||||||
|
|
||||||
| trait MappedToBase extends Any { | ||||||
| type Underlying | ||||||
| def value: Underlying | ||||||
| } | ||||||
|
|
||||||
| object MappedToBase { | ||||||
| implicit def mappedToIsomorphism[E <: MappedToBase]: Isomorphism[E, E#Underlying] = macro mappedToIsomorphismMacroImpl[E] | ||||||
|
|
||||||
| def mappedToIsomorphismMacroImpl[E <: MappedToBase](c: Context)(implicit e: c.WeakTypeTag[E]): c.Expr[Isomorphism[E, E#Underlying]] = { | ||||||
| import c.universe._ | ||||||
| // Check that E <: MappedToBase. Due to SI-8351 the macro can be expanded before scalac has | ||||||
| // checked this. The error message here will never be seen because scalac's subsequent bounds | ||||||
| // check fails, overriding our error (or backtracking in implicit search). | ||||||
| if (!(e.tpe <:< c.typeOf[MappedToBase])) | ||||||
| c.abort(c.enclosingPosition, "Work-around for SI-8351 leading to illegal macro-invocation -- You should not see this message") | ||||||
|
||||||
| c.abort(c.enclosingPosition, "Work-around for SI-8351 leading to illegal macro-invocation -- You should not see this message") | |
| c.abort(c.enclosingPosition, "Invalid macro invocation: The type parameter must extend MappedToBase. Please ensure that your type definition satisfies this requirement.") |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using println for error reporting in library code is not recommended. Consider using a proper logging framework or removing this debug statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class lacks documentation explaining its purpose and usage. Consider adding a scaladoc comment describing how it provides column type conversion for isomorphic types.