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

Scala 3 migration #158

Merged
merged 44 commits into from
Mar 20, 2024
Merged

Conversation

aShevc
Copy link
Contributor

@aShevc aShevc commented Mar 12, 2024

This migration is verified by running tests coverage.
Changes in this PR:

  • implicit conversions got reworked according to official migration guide
  • Cast case class and ComparableWith trait needed to be moved from mixin traits to Magnet trait, otherwise Scala 3 compiler crash occurred
  • as a driveby updated Pekko version

EDIT:
Additional changes in tests:
Due to errors that specifically occured in the CI/CD build, the following changes has been added to tests

  • Usages of === method in dsl tests replaced by isEq, as === was evaluated to Boolean
  • Moved Type cast method to scala-2 folder as it relies on extension methods
  • In tests using InOps methods implicit conversions were not applied properly. There was a need to explicitly specify type annotation for the fields on which in methods were applied. This may require more deep work on this in the future to figure out the root cause of the issue

@@ -3,7 +3,7 @@ package com.crobox.clickhouse.dsl
import scala.util.Try

trait Table {
val database: String
def database: String = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why did you instantiate this to an empty string? In the previous scenario compile errors would popup if not set. Now there might be a chance that an empty database is selected (which should be avoided imho)

def greater(col1: ConstOrColMagnet[_], col2: ConstOrColMagnet[_]): ExpressionColumn[Boolean] = ComparisonColumn(col1 , ">", col2)
def lessOrEquals(col1: ConstOrColMagnet[_], col2: ConstOrColMagnet[_]): ExpressionColumn[Boolean] = ComparisonColumn(col1 , "<=", col2)
def greaterOrEquals(col1: ConstOrColMagnet[_], col2: ConstOrColMagnet[_]): ExpressionColumn[Boolean] = ComparisonColumn(col1 , ">=", col2)
def _equals(col1: ConstOrColMagnet[_], col2: ConstOrColMagnet[_]): ExpressionColumn[Boolean] = ComparisonColumn(col1, "=", col2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like the _ (which was already there btw). Can't we get rid of it? Or make this one deprecated and add the 'equals()' method. If compiler starts complaining, perhaps rename it to: 'isEquals' or something similar?

// ComparabeWith trait and Cast case class were members of ComparisonFunctions and TypeCastFunctions trait
// respectively. But placing them in the mixin traits causes Scala 3 compiler to crash. Hence, placing these
// constructs here is a workaround allowing for the codebase to be compiled with Scala 3.
trait ComparableWith[M <: Magnet[_]] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In scala 3 the [_] should be rewritten to [?] right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lwolters Eventually in the future, yes. See https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html but for now it would be too big of a hassle to change

@@ -120,7 +154,7 @@ trait Magnets {
with StringSearchOps
with EmptyNonEmptyCol[C]

implicit def stringColMagnetFromString[T <: String: QueryValue](s: T): StringColMagnet[String] =
implicit def stringColMagnetFromString[T <: String : QueryValue](s: T): StringColMagnet[String] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space between String and QueryValue doesn't seem right. Looks like formatting issues

Copy link
Contributor

@lwolters lwolters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Some minor code formatting related remarks

@sjoerdmulder sjoerdmulder merged commit 8509bf5 into crobox:master Mar 20, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

3 participants