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

Problem inserting nested Document type #19

Closed
ohde opened this issue Oct 1, 2014 · 10 comments
Closed

Problem inserting nested Document type #19

ohde opened this issue Oct 1, 2014 · 10 comments

Comments

@ohde
Copy link

ohde commented Oct 1, 2014

user is of type User extends Document and includes another type extending Document.

Fails:

insert(user)

Client is buggy (failed to deserialize query).

Works:

insertMap(Seq(Reflector.toMap(user))
@ohde
Copy link
Author

ohde commented Oct 2, 2014

This is a newly introduced bug, as all of my nested inserts no longer work.

@kclay
Copy link
Owner

kclay commented Oct 2, 2014

Can u give me an example of your case class declaration so I can make a test

On October 1, 2014 9:46:53 PM CDT, Michael notifications@github.com wrote:

This is a newly introduced bug, as all of my nested inserts no longer
work.


Reply to this email directly or view it on GitHub:
#19 (comment)

@ohde
Copy link
Author

ohde commented Oct 2, 2014

case class Address(labels: List[String] = List("sample")) extends Document

case class User(name: String, active: Boolean = true, address: Address = Address(), id: Option[String] = None) extends Document

@kclay
Copy link
Owner

kclay commented Oct 12, 2014

Fixed in 0.4.5. Sorry for the delay

@kclay kclay closed this as completed Oct 12, 2014
@ohde
Copy link
Author

ohde commented Oct 17, 2014

Thanks worked great.

@ohde
Copy link
Author

ohde commented Feb 1, 2015

Please reopen. I had to switching back to using:
insertMap(Seq(Reflector.toMap(user))

@kclay
Copy link
Owner

kclay commented Feb 1, 2015

I'll check this one today

On February 1, 2015 4:16:46 AM CST, Michael notifications@github.com wrote:

Please reopen. I had to switching back to using:
insertMap(Seq(Reflector.toMap(user))


Reply to this email directly or view it on GitHub:
#19 (comment)

@kclay kclay reopened this Feb 1, 2015
@kclay
Copy link
Owner

kclay commented Feb 1, 2015

Can't you provide a example of your document. Here is my current test and it seems to be passing:

case class NestedAddress(labels: List[String]) extends Document

case class NestedUser(name: String, active: Boolean , address: NestedAddress, id: Option[String] = None) extends Document

class NestedTest extends FunSuite with WithBase {


  test("nested documents") {

    val user = NestedUser("foo",true,NestedAddress(List("hello")))
    val foos= r.tableAs[NestedUser]("foo")
    val term = foos.insert(user)
    val query = version3.toQuery(term, 1, None, Map.empty)
    val json = query.json
    println(json)
   val answer =for {
      res <- term.toOpt
      user2 <- foos.get(res.generatedKeys.head).toOpt
    } yield user2

    println(answer) 
// Some(NestedUser(foo,true,NestedAddress(List(hello)),Some(d0189ff4-70fa-46c0-bc6a-cee5450a5b64)))

  }


}```

@kclay
Copy link
Owner

kclay commented Feb 1, 2015

Tested a few more nested

case class NestedZip(zip:String) extends Document
case class NestedStreet(zip:NestedZip) extends Document
case class NestedAddress(street:NestedStreet) extends Document
case class NestedUser(name: String, active: Boolean , address: NestedAddress, id: Option[String] = None) extends Document

I would double check that all case classes extend Document

@ohde
Copy link
Author

ohde commented Feb 1, 2015

I see the difference. My user case class includes an object that doesn't inherit from Document as it is from an imported class and is inserting null value for that field.

However, this was not always the case, 0.4.4 allows me to insert this object with no problem. Let me know if you need me to provide further examples.

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