Closed nbest937 closed 11 years ago
Perhaps this is a better/simpler illustration, building on examples from your docs:
> buf <- mongo.bson.buffer.create()
> mongo.bson.buffer.append.bool(buf, "bools", c(TRUE, FALSE, FALSE))
> [1] TRUE
> b <- mongo.bson.from.buffer(buf)
> b
bools : 4
0 : 8 true
1 : 8 false
2 : 8 false
> buf <- mongo.bson.buffer.create()
> mongo.bson.buffer.append.bool(buf, "bools", c(TRUE, FALSE, NA))
[1] TRUE
> b <- mongo.bson.from.buffer(buf)
> b
bools : 4
0 : 8 true
1 : 8 false
2 : 8 true
Would you call this a bug or do I need to come up with a work-around to get null
s in there?
You'll need to come up with a work around. "NA" is an 'R-ism'. There is currently no way to store such a value for a boolean using BSON. As far as rmongodb and MongoDB and BSON go, non-zero is true.
Gerald, thanks for the rmongodb package. I think I may have stumbled upon a problem. I hope this is constructive. As far as I can tell, a value of NA in a logical variable that is a member of a list gets translated to to 'true' in the BSON data structure. Here is what I am looking at:
Does anything jump out at you here? The input list was created using an
as.list( read.csv( text= ))
call. Pretty straightforward I think. Thanks for taking a look. Please let me know if I can help work this out in any way.Maybe I should try to find a record with non-NA values and see what it does then? Will post follow-up.