Skip to content

Commit

Permalink
Preparing for Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerdmulder committed Feb 23, 2024
1 parent 338ebd5 commit 32d7c15
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 90 deletions.
37 changes: 10 additions & 27 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
style = defaultWithAlign
preset = defaultWithAlign
//@formatter on
align {
tokens = [
{code = "=>", owner = "Case"}
{code = "extends", owner = "Defn.(Class|Trait|Object)"}
{code = "//", owner = ".*"}
{code = "{", owner = "Template"}
{code = "}", owner = "Template"}
{code = "%", owner = "Term.ApplyInfix"}
{code = "%%", owner = "Term.ApplyInfix"}
{code = "%%%", owner = "Term.ApplyInfix"}
{code = "⇒", owner = "Case"}
{code = "<-", owner = "Enumerator.Generator"}
{code = "←", owner = "Enumerator.Generator"}
{code = "->", owner = "Term.ApplyInfix"}
{code = "→", owner = "Term.ApplyInfix"}
{code = "=", owner = "(Enumerator.Val|Defn.(Va(l|r)|Def|Type))"}
]
}
danglingParentheses = true
docstrings = JavaDoc
indentOperator = spray
maxColumn = 120
rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
unindentTopLevelOperators = true
project.git = true
newlines.alwaysBeforeTopLevelStatements = true
version = 3.7.17
runner.dialect = scala3
align.preset = more
danglingParentheses.preset = true
docstrings.style = Asterisk
indentOperator.preset = spray
maxColumn = 120
rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
project.git = true
37 changes: 21 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import Build.*

// Scala Formatting
ThisBuild / scalafmtVersion := "1.5.1"
ThisBuild / scalafmtOnCompile := false // all projects
ThisBuild / scalafmtTestOnCompile := false // all projects

releaseCrossBuild := true

sonatypeProfileName := "com.crobox"

lazy val root = (project in file("."))
.settings(
publish := {},
publish := {},
publishArtifact := false,
inThisBuild(
List(
organization := "com.crobox.clickhouse",
scalaVersion := "2.13.8",
crossScalaVersions := List("2.13.8"),
organization := "com.crobox.clickhouse",
scalaVersion := "2.13.13",
crossScalaVersions := List("2.13.13"),
javacOptions ++= Seq("-g", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "11", "-target", "11"),
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-language:_", "-encoding", "UTF-8"),
scalacOptions ++= Seq(
"-release:11",
"-Xsource:3-cross",
"-quickfix:any",
"-unchecked",
"-deprecation",
"-feature",
"-language:_",
"-encoding",
"UTF-8"
),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Expand Down Expand Up @@ -58,33 +63,33 @@ lazy val client: Project = (project in file("client"))
.configs(Config.CustomIntegrationTest)
.settings(Config.testSettings: _*)
.settings(
name := "client",
name := "client",
sbtrelease.ReleasePlugin.autoImport.releasePublishArtifactsAction := PgpKeys.publishSigned.value,
libraryDependencies ++= Seq(
"io.spray" %% "spray-json" % "1.3.6",
"org.apache.pekko" %% "pekko-actor" % PekkoVersion,
"org.apache.pekko" %% "pekko-stream" % PekkoVersion,
"org.apache.pekko" %% "pekko-http" % PekkoHttpVersion,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"joda-time" % "joda-time" % "2.12.5"
) ++ Seq("org.apache.pekko" %% "pekko-testkit" % PekkoVersion % Test) ++ Build.testDependencies.map(_ % Test)
"joda-time" % "joda-time" % "2.12.7"
) ++ Seq("org.apache.pekko" %% "pekko-testkit" % PekkoVersion % Test) ++ Build.testDependencies.map(_ % Test)
)

lazy val dsl = (project in file("dsl"))
.dependsOn(client, client % "test->test", testkit % Test)
.configs(Config.CustomIntegrationTest)
.settings(Config.testSettings: _*)
.settings(
name := "dsl",
name := "dsl",
sbtrelease.ReleasePlugin.autoImport.releasePublishArtifactsAction := PgpKeys.publishSigned.value,
libraryDependencies ++= Seq("com.google.guava" % "guava" % "23.0", "com.typesafe" % "config" % "1.4.2")
libraryDependencies ++= Seq("com.google.guava" % "guava" % "33.0.0-jre", "com.typesafe" % "config" % "1.4.3")
)
// .settings(excludeDependencies ++= Seq(ExclusionRule("org.apache.pekko")))

lazy val testkit = (project in file("testkit"))
.dependsOn(client)
.settings(
name := "testkit",
name := "testkit",
sbtrelease.ReleasePlugin.autoImport.releasePublishArtifactsAction := PgpKeys.publishSigned.value,
libraryDependencies ++= Build.testDependencies
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class ClickhouseTimeSeriesIT extends DslITSpec with TableDrivenPropertyChecks {
case class CustomResult(time: IntervalStart, shields: String)

object CustomResult {
implicit val format = jsonFormat2(CustomResult.apply)
implicit val format: spray.json.RootJsonFormat[ClickhouseTimeSeriesIT.this.CustomResult] = jsonFormat2(CustomResult.apply)
}

implicit val clickhouseClient = clickClient
implicit val clickhouseClient: com.crobox.clickhouse.ClickhouseClient = clickClient
val startInterval = DateTime.parse("2019-03-01").withTimeAtStartOfDay().withZone(DateTimeZone.UTC)
val secondsId = UUID.randomUUID()
val dayId = UUID.randomUUID()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.crobox.clickhouse.dsl.column

import com.crobox.clickhouse.DslITSpec
import com.crobox.clickhouse.dsl.misc.LogicalOperatorImprovements.ExpressionColumnImpr
import com.crobox.clickhouse.dsl.select
import com.crobox.clickhouse.dsl._

import java.util.UUID

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crobox.clickhouse.dsl.column

import com.crobox.clickhouse.dsl.{Const, EmptyColumn, ExpressionColumn}
import com.crobox.clickhouse.dsl.marshalling.QueryValueFormats.BooleanQueryValue

trait InFunctions { self: Magnets =>

Expand Down
60 changes: 30 additions & 30 deletions dsl/src/main/scala/com/crobox/clickhouse/dsl/column/Magnets.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.crobox.clickhouse.dsl.column

import java.util.UUID

import com.crobox.clickhouse.dsl.marshalling.{QueryValue, QueryValueFormats}
import com.crobox.clickhouse.dsl.marshalling.QueryValueFormats.BooleanQueryValue
import com.crobox.clickhouse.dsl.{Const, EmptyColumn, OperationalQuery, Table, TableColumn}
import org.joda.time.{DateTime, LocalDate}

import java.util.UUID

trait Magnets {
self: ArithmeticFunctions
with ComparisonFunctions
Expand All @@ -21,16 +22,15 @@ trait Magnets {
/**
* Magnet pattern
*
* The pattern provides implicit conversion to wrapper classes,
* this allows the DSL to accept multiple compatible column types in a single function.
* The pattern provides implicit conversion to wrapper classes, this allows the DSL to accept multiple compatible
* column types in a single function.
*/
trait Magnet[+C] {
val column: TableColumn[C]
}

/**
* Any constant or column.
* Sidenote: The current implementation doesn't represent collections.
* Any constant or column. Sidenote: The current implementation doesn't represent collections.
*/
trait ConstOrColMagnet[+C] extends Magnet[C] with ScalaBooleanFunctionOps with InOps

Expand Down Expand Up @@ -71,14 +71,14 @@ trait Magnets {

implicit def InFuncRHMagnetFromQuery(s: OperationalQuery): InFuncRHMagnet =
new InFuncRHMagnet {
override val column = EmptyColumn
override val column: TableColumn[Nothing] = EmptyColumn
override val query: Option[OperationalQuery] = Some(s)
}

implicit def InFuncRHMagnetFromTable(s: Table): InFuncRHMagnet =
new InFuncRHMagnet {
override val column = EmptyColumn
override val tableRef: Option[Table] = Some(s)
override val column: TableColumn[Nothing] = EmptyColumn
override val tableRef: Option[Table] = Some(s)
}

/**
Expand All @@ -88,8 +88,8 @@ trait Magnets {

implicit def arrayColMagnetFromIterableConst[T: QueryValue](s: scala.Iterable[T]): ArrayColMagnet[scala.Iterable[T]] =
new ArrayColMagnet[scala.Iterable[T]] {
val qvForIterable = QueryValueFormats.queryValueToSeq(implicitly[QueryValue[T]])
override val column = Const(s)(qvForIterable)
val qvForIterable = QueryValueFormats.queryValueToSeq(implicitly[QueryValue[T]])
override val column: Const[Iterable[T]] = Const(s)(qvForIterable)
}

implicit def arrayColMagnetFromIterableCol[C](s: TableColumn[scala.Iterable[C]]): ArrayColMagnet[scala.Iterable[C]] =
Expand Down Expand Up @@ -152,22 +152,22 @@ trait Magnets {

implicit def ddtFromDateCol[T <: TableColumn[LocalDate]](s: T): DateOrDateTime[LocalDate] =
new DateOrDateTime[LocalDate] {
override val column = s
override val column: T = s
}

implicit def ddtFromDateTimeCol[T <: TableColumn[DateTime]](s: T): DateOrDateTime[DateTime] =
new DateOrDateTime[DateTime] {
override val column = s
override val column: T = s
}

implicit def ddtFromDate[T <: LocalDate: QueryValue](s: T): DateOrDateTime[LocalDate] =
new DateOrDateTime[LocalDate] {
override val column = toDate(s)
override val column: DateRep = toDate(s)
}

implicit def ddtFromDateTime[T <: DateTime: QueryValue](s: T): DateOrDateTime[DateTime] =
new DateOrDateTime[DateTime] {
override val column = toDateTime(s)
override val column: DateTimeRep = toDateTime(s)
}

sealed trait LogicalOpsMagnet extends LogicalOps {
Expand Down Expand Up @@ -225,72 +225,72 @@ trait Magnets {

implicit def numericFromLong[T <: Long: QueryValue](s: T): NumericCol[Long] =
new NumericCol[Long] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromInt[T <: Int: QueryValue](s: T): NumericCol[Int] =
new NumericCol[Int] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromDouble[T <: Double: QueryValue](s: T): NumericCol[Double] =
new NumericCol[Double] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromFloat[T <: Float: QueryValue](s: T): NumericCol[Float] =
new NumericCol[Float] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromBigInt[T <: BigInt: QueryValue](s: T): NumericCol[BigInt] =
new NumericCol[BigInt] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromBigDecimal[T <: BigDecimal: QueryValue](s: T): NumericCol[BigDecimal] =
new NumericCol[BigDecimal] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromBoolean[T <: Boolean: QueryValue](s: T): NumericCol[Boolean] =
new NumericCol[Boolean] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

implicit def numericFromLongCol[T <: TableColumn[Long]](s: T): NumericCol[Long] =
new NumericCol[Long] {
override val column = s
override val column: T = s
}

implicit def numericFromIntCol[T <: TableColumn[Int]](s: T): NumericCol[Int] =
new NumericCol[Int] {
override val column = s
override val column: T = s
}

implicit def numericFromDoubleCol[T <: TableColumn[Double]](s: T): NumericCol[Double] =
new NumericCol[Double] {
override val column = s
override val column: T = s
}

implicit def numericFromFloatCol[T <: TableColumn[Float]](s: T): NumericCol[Float] =
new NumericCol[Float] {
override val column = s
override val column: T = s
}

implicit def numericFromBigIntCol[T <: TableColumn[BigInt]](s: T): NumericCol[BigInt] =
new NumericCol[BigInt] {
override val column = s
override val column: T = s
}

implicit def numericFromBigDecimalCol[T <: TableColumn[BigDecimal]](s: T): NumericCol[BigDecimal] =
new NumericCol[BigDecimal] {
override val column = s
override val column: T = s
}

implicit def numericFromBooleanCol[T <: TableColumn[Boolean]](s: T): NumericCol[Boolean] =
new NumericCol[Boolean] {
override val column = s
override val column: T = s
}

/**
Expand All @@ -307,7 +307,7 @@ trait Magnets {

implicit def emptyNonEmptyFromIterable[T <: Iterable[_]: QueryValue](s: T): EmptyNonEmptyCol[T] =
new EmptyNonEmptyCol[T] {
override val column = Const(s)
override val column: Const[T] = Const(s)
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.crobox.clickhouse.dsl.column

import com.crobox.clickhouse.dsl.{Const, TableColumn}
import com.crobox.clickhouse.dsl._

trait ScalaBooleanFunctions {
self: Magnets with ComparisonFunctions =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crobox.clickhouse.dsl.misc

import com.crobox.clickhouse.dsl.{ExpressionColumn, NativeColumn}
import com.crobox.clickhouse.dsl._
import org.joda.time.{DateTime, DateTimeZone, LocalDate}

trait DateConditions {
Expand Down
6 changes: 3 additions & 3 deletions dsl/src/test/scala/com/crobox/clickhouse/TestSchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ trait TestSchema {
fifthColumn: String,
sixthColumn: String)

implicit val entry1Format =
implicit val entry1Format: spray.json.RootJsonFormat[TestSchema.this.Table1Entry] =
jsonFormat(Table1Entry.apply, "shield_id", "ts", "numbers")
implicit val entry2Format =
implicit val entry2Format: spray.json.RootJsonFormat[TestSchema.this.Table2Entry] =
jsonFormat(Table2Entry.apply, "item_id", "column_1", "column_2", "column_3", "column_4")
implicit val entry3Format =
implicit val entry3Format: spray.json.RootJsonFormat[TestSchema.this.Table3Entry] =
jsonFormat(Table3Entry.apply, "item_id", "column_2", "column_4", "column_5", "column_6")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crobox.clickhouse.dsl.column

import com.crobox.clickhouse.DslTestSpec

import com.crobox.clickhouse.dsl.JoinQuery.InnerJoin
import com.crobox.clickhouse.dsl._

Expand Down
6 changes: 3 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import sbt._

object Build {

val PekkoVersion = "1.0.1"
val PekkoHttpVersion = "1.0.0"
val PekkoVersion = "1.0.2"
val PekkoHttpVersion = "1.0.1"

val testDependencies = Seq("org.scalatest" %% "scalatest" % "3.2.15", "ch.qos.logback" % "logback-classic" % "1.4.7")
val testDependencies = Seq("org.scalatest" %% "scalatest" % "3.2.18", "ch.qos.logback" % "logback-classic" % "1.4.14")
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.6
sbt.version=1.9.8
Loading

0 comments on commit 32d7c15

Please sign in to comment.