-
Notifications
You must be signed in to change notification settings - Fork 76
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
Support Scala3 #474
Support Scala3 #474
Conversation
25f953a
to
2b83f43
Compare
|
||
private[anorm] trait PackageCompat: | ||
|
||
extension (query: SqlQuery) |
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.
More Scala2 implicit conversion that previously pimps SqlQuery
as SimpleSql[Row]
with extended combinators
@@ -57,12 +57,8 @@ private[anorm] object SealedRowParserImpl { | |||
val caseName = TermName(c.freshName("discriminated")) | |||
val key = q"$discriminate(${subclass.typeSymbol.fullName})" | |||
val caseDecl = q"val $caseName = $key" | |||
val subtype = { | |||
if (subclass.typeSymbol.asClass.typeParams.isEmpty) subclass |
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.
Generic subclass is not supported anyway (error raised therebefore)
@@ -0,0 +1,3 @@ | |||
package com.github.ghik.silencer | |||
|
|||
class silent(s: String = "") extends scala.annotation.StaticAnnotation |
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.
Compatibility workaround
@@ -262,7 +277,6 @@ object Sql { // TODO: Rename to SQL | |||
private def toSql(ts: List[StatementToken], buf: StringBuilder): StringBuilder = ts.foldLeft(buf) { | |||
case (sql, StringToken(t)) => sql ++= t | |||
case (sql, PercentToken) => sql += '%' | |||
case (sql, _) => sql |
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.
Unreachable
@@ -0,0 +1,104 @@ | |||
package anorm | |||
|
|||
private[anorm] trait MacroOptions { |
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.
Common to both versions
@@ -0,0 +1,180 @@ | |||
package anorm | |||
|
|||
trait RowParser[+A] extends (Row => SqlResult[A]) { parent => |
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.
Extracted from SqlParser.scala
@@ -567,185 +567,6 @@ sealed trait DeprecatedSqlParser { _: SqlParser.type => | |||
@SuppressWarnings(Array("ClassNames")) | |||
final case class ~[+A, +B](_1: A, _2: B) | |||
|
|||
object RowParser { |
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.
Moved as separate file
22d381a
to
d8922c0
Compare
import scala.language.experimental.macros | ||
import scala.reflect.macros.whitebox | ||
|
||
/** Only for internal purposes */ |
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.
Moved down or extracted to common MacroOptions
trait
1c0fbec
to
c3bb316
Compare
cfe9d74
to
514c03c
Compare
|
||
// Not enough column names for class parameters | ||
shapeless.test.illTyped("""anorm.Macro.parser[Foo[Int]]("Foo", "Bar")""") | ||
"not be resolved" in { |
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.
Improve compile-time tests
@@ -263,8 +325,23 @@ lazy val `anorm-postgres` = (project in file("postgres")) | |||
|
|||
lazy val `anorm-enumeratum` = (project in file("enumeratum")) | |||
.settings( | |||
sourceDirectory := { | |||
if (scalaBinaryVersion.value == "3") new java.io.File("/no/sources") |
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.
Enumeratum not released to Scala 3
@@ -14,6 +14,20 @@ sealed trait SqlResult[+A] { self => | |||
case e @ Error(_) => e | |||
} | |||
|
|||
def collect[B](f: PartialFunction[A, B]): SqlResult[B] = self match { |
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.
New combinator
No description provided.