Closed ohde closed 9 years ago
This is a newly introduced bug, as all of my nested inserts no longer work.
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: https://github.com/kclay/rethink-scala/issues/19#issuecomment-57574395
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
Fixed in 0.4.5. Sorry for the delay
Thanks worked great.
Please reopen. I had to switching back to using: insertMap(Seq(Reflector.toMap(user))
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: https://github.com/kclay/rethink-scala/issues/19#issuecomment-72359119
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)))
}
}```
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
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.
user is of type User extends Document and includes another type extending Document.
Fails:
Client is buggy (failed to deserialize query).
Works: