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

Introduce MongoProvidedFormat to skip generating MongoFormatters. Now… #542

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

benko-balog
Copy link
Contributor

… the skipping can also handle types with parameters.

  • This was necessary because we realized that the type we actually want to skip has one type parameter.
  • This code cannot handle more than 1 type parameters for now.
  • We switched from the automatic approach to one that uses annotations, I'm not 100% sure this is better, but the code is simpler.

… the skipping can also handle types with parameters.
@benko-balog benko-balog requested a review from yanns as a code owner October 18, 2023 09:45
subtypes.partition(mongoFormatExists(c))
val singleParamTypes = subtypesWithFormatter.filter(_.asType.typeParams.length == 1)

val idents = Ident(symbol.name) :: (subtypes -- singleParamTypes).map { s =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We generate custom TypeSelectors for types with type parameters, so we remove them from this list. (The idents list will be the type parameter list of the mongoTypeSwitch method)

@@ -75,13 +75,13 @@ class SumTypesDerivingSpec extends AnyWordSpec with Matchers {
check(Color9.format, Color9.Custom("2356"), dbObj("type" -> "Custom", "rgb" -> "2356"))
}

"Formatters could be overridden for objects" in {
"allow for providing custom instances for objects" in {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change these so they with the Serializing sum types must ... wording

@benko-balog benko-balog added this pull request to the merge queue Oct 18, 2023
Merged via the queue into main with commit 182b988 Oct 18, 2023
7 checks passed
@benko-balog benko-balog deleted the deriveMongoFormat_skip_2 branch October 18, 2023 10:06
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