julianpeeters / avrohugger

Generate Scala case class definitions from Avro schemas
Apache License 2.0
201 stars 120 forks source link

fix using coproduct for non-coproduct #180

Closed LeonPoon closed 11 months ago

LeonPoon commented 11 months ago

As such:

diff --git a/avrohugger-core/src/test/expected/specific/OptionEitherShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala b/avrohugger-core/src/test/expected/specific/OptionEitherShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
index 85d4ff6..1438735 100644
--- a/avrohugger-core/src/test/expected/specific/OptionEitherShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
+++ b/avrohugger-core/src/test/expected/specific/OptionEitherShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
@@ -4,7 +4,7 @@ package com.example.avrohugger.unions_with_coproduct_avsc2
 import scala.annotation.switch

 final case class UnionOfOneNonNullType(var f3: Map[String, String]) extends org.apache.avro.specific.SpecificRecordBase {
-  def this() = this(shapeless.Coproduct[Map[String, String] :+: CNil](Map("" -> "")))
+  def this() = this(Map())
   def get(field$: Int): AnyRef = {
     (field$: @switch) match {
       case 0 => {
diff --git a/avrohugger-core/src/test/expected/specific/OptionShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala b/avrohugger-core/src/test/expected/specific/OptionShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
index 85d4ff6..1438735 100644
--- a/avrohugger-core/src/test/expected/specific/OptionShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
+++ b/avrohugger-core/src/test/expected/specific/OptionShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
@@ -4,7 +4,7 @@ package com.example.avrohugger.unions_with_coproduct_avsc2
 import scala.annotation.switch

 final case class UnionOfOneNonNullType(var f3: Map[String, String]) extends org.apache.avro.specific.SpecificRecordBase {
-  def this() = this(shapeless.Coproduct[Map[String, String] :+: CNil](Map("" -> "")))
+  def this() = this(Map())
   def get(field$: Int): AnyRef = {
     (field$: @switch) match {
       case 0 => {
diff --git a/avrohugger-core/src/test/expected/specific/OptionalShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala b/avrohugger-core/src/test/expected/specific/OptionalShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
index eed1e7a..79e7525 100644
--- a/avrohugger-core/src/test/expected/specific/OptionalShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
+++ b/avrohugger-core/src/test/expected/specific/OptionalShapelessCoproduct/com/example/avrohugger/unions_with_coproduct_avsc2/UnionOfOneNonNullType.scala
@@ -6,7 +6,7 @@ import scala.annotation.switch
 import shapeless.{:+:, CNil, Coproduct}

 final case class UnionOfOneNonNullType(var f3: Map[String, String] :+: CNil) extends org.apache.avro.specific.SpecificRecordBase {
-  def this() = this(shapeless.Coproduct[Map[String, String] :+: CNil](Map("" -> "")))
+  def this() = this(shapeless.Coproduct[Map[String, String] :+: CNil](Map()))
   def get(field$: Int): AnyRef = {
     (field$: @switch) match {
       case 0 => {
julianpeeters commented 11 months ago

Great, thanks again. Out now in avrohugger 1.5.6 and sbt-avrohugger 2.5.6