Skip to content

Commit

Permalink
more robust macro implementation, test for edge case
Browse files Browse the repository at this point in the history
fixes #265
  • Loading branch information
mpollmeier committed Nov 9, 2018
1 parent 653eeac commit a6aff29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ class MarshallableSpec extends WordSpec with Matchers {
results shouldBe Set(cc1, cc2)
}

case class EmptyCC()
"handle case class without elements" in new Fixture {
val m = implicitly[Marshallable[EmptyCC]]
}

trait Fixture {
val graph = TinkerGraph.open.asScala
}
Expand Down
5 changes: 4 additions & 1 deletion macros/src/main/scala/gremlin/scala/Marshallable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ object Marshallable {
$label,
_root_.scala.collection.immutable.List(..$fromCCParams)
.flatten
.filter(kv => _root_.scala.Option(kv._2).isDefined)
.filter { kv =>
kv.isInstanceOf[Product2[_, _]] &&
kv.asInstanceOf[Product2[_, _]]._2 != null
}
)
def toCC(element: _root_.gremlin.scala.Element): $tpe = $companion(..$toCCParams)
}
Expand Down

0 comments on commit a6aff29

Please sign in to comment.