mongosoup/rmongodb — pull request #28 by dtenenba (2014-01-24 23:05:15+00:00)
Title: move RJSONIO from Depends to Impports, import it in NAMESPACE

Hi,

You have RJSONIO in the Depends: field of rmongodb's DESCRIPTION file. It needs to be in Imports: (with imports(RJSONIO) in NAMESPACE).

Here is why: if I make a package that depends on rmongodb, and then I call mongo.bson.from.JSON(), it fails saying it can't find the isValidJSON function.

This is especially hairy for us as our package uses rjson, not RJSONIO, and if we try to work around this issue with various hacks we get a lot of confusion between the two packages' different versions of identically named functions. We could find no satisfactory way to work around the issue, and we are using a version of rmongodb that has this patch applied. But that's not a long-term solution so I hope you'll accept this pull request.

After all, our package has no direct dependencies on RJSONIO so we should not have to declare a dependency on it.

If you accept this pull request, the problem will go away.

The following script demonstrates the problem. WIthout the pull request, the script will fail as shown. With it, it works.

library(devtools)
path <- file.path(tempdir(), "myDefaultPackage")

if (file.exists(path)) unlink(path, recursive=TRUE)
create(path, list(Author="me", Maintainer="Me ",
Imports="rmongodb"))
cat("import(rmongodb)\nexport(f)", file=file.path(path, "NAMESPACE"))

cat("f <- function() mongo.bson.from.JSON('{\"foo\": \"bar\"}')\n",
file=file.path(path, "R", "code.R"))

install.packages(path, repos=NULL, type="source")

library(myDefaultPackage)
f()

## works with my patch, but without it you get:

## Error in mongo.bson.from.JSON("{\"foo\": \"bar\"}") :
## could not find function "isValidJSON"

Thanks!
Dan
@mrjc42
@mtmorgan