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

Case Class Mashalling - Compile Error when defining CC in Block Scope #184

Open
frne opened this issue Feb 13, 2017 · 1 comment
Open

Case Class Mashalling - Compile Error when defining CC in Block Scope #184

frne opened this issue Feb 13, 2017 · 1 comment

Comments

@frne
Copy link

frne commented Feb 13, 2017

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...

@mpollmeier
Copy link
Owner

it's a restriction of black box macros I believe..

mpollmeier added a commit that referenced this issue Feb 14, 2017
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

No branches or pull requests

2 participants