gremlin-scala
gremlin-scala copied to clipboard
Case Class Mashalling - Compile Error when defining CC in Block Scope
Is it intentional, that case classes must be defined at top level and cannot be inside other scope?
Works:
class CaseClassSpec extends FlatSpec with Matchers {
@label("example")
case class Example(@id id: Option[Int],
longValue: Long,
stringValue: Option[String])
"Gremlin" should "be able to Marshall case-classes" in {
val graph = TinkerGraph.open.asScala
val example = Example(None, Long.MaxValue, Some("optional value"))
val v = graph + example
v.toCC[Example] // equal to `example`, but with id set
// find all vertices with the label of the case class `Example`
graph.V.hasLabel[Example]
// modify the vertex like a case class
v.updateAs[Example](_.copy(longValue = 0L))
}
}
Does not work:
class CaseClassSpec extends FlatSpec with Matchers {
"Gremlin" should "be able to Marshall case-classes" in {
@label("example")
case class Example(@id id: Option[Int],
longValue: Long,
stringValue: Option[String])
val graph = TinkerGraph.open.asScala
val example = Example(None, Long.MaxValue, Some("optional value"))
val v = graph + example
v.toCC[Example] // equal to `example`, but with id set
// find all vertices with the label of the case class `Example`
graph.V.hasLabel[Example]
// modify the vertex like a case class
v.updateAs[Example](_.copy(longValue = 0L))
}
}
Error:
Error:(19, 19) not found: value <none>
val v = graph + example
It's not a requirement to work, but maybe the error could be a bit cleaner, or stated in the readme...
it's a restriction of black box macros I believe..