Changeset: f0059d79f69a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f0059d79f69a
Modified Files:
clients/R/MonetDB.R/NAMESPACE
clients/R/MonetDB.R/R/dbi.R
tools/embedded/Tests/dbi.R
Branch: embedded
Log Message:
other connection object creation method
diffs (64 lines):
diff --git a/clients/R/MonetDB.R/NAMESPACE b/clients/R/MonetDB.R/NAMESPACE
--- a/clients/R/MonetDB.R/NAMESPACE
+++ b/clients/R/MonetDB.R/NAMESPACE
@@ -2,6 +2,7 @@ import(DBI,digest,methods,codetools,util
# export only driver constructor, everything else is DBI stuff..
export(MonetDB,MonetR,MonetDBR,MonetDB.R)
+export(MonetDBLite,monetdblite,RMonetDBLite,rmonetdblite)
export(monet.read.csv,monetdb.read.csv)
# this one is not in the DBI
exportMethods(dbSendUpdate,dbSendUpdateAsync,dbTransaction,mdbapply)
diff --git a/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R
--- a/clients/R/MonetDB.R/R/dbi.R
+++ b/clients/R/MonetDB.R/R/dbi.R
@@ -6,19 +6,16 @@ setOldClass(c("sockconn", "connection",
### MonetDBDriver
setClass("MonetDBDriver", representation("DBIDriver"))
+setClass("MonetDBEmbeddedDriver", representation("MonetDBDriver"))
# allow instantiation of this driver with MonetDB to allow existing programs
to work
-MonetR <- MonetDB <- MonetDBR <- MonetDB.R <- function() {
- new("MonetDBDriver")
-}
+MonetR <- MonetDB <- MonetDBR <- MonetDB.R <- function() new("MonetDBDriver")
-setMethod("dbIsValid", "MonetDBDriver", def=function(dbObj, ...) {
- return(invisible(TRUE)) # driver object cannot be invalid
-})
+MonetDBLite <- monetdblite <- RMonetDBLite <- rmonetdblite <- function()
new("MonetDBEmbeddedDriver")
-setMethod("dbUnloadDriver", "MonetDBDriver", def=function(drv, ...) {
- return(invisible(TRUE)) # there is nothing to really unload here...
-})
+setMethod("dbIsValid", "MonetDBDriver", def=function(dbObj, ...)
invisible(TRUE))
+
+setMethod("dbUnloadDriver", "MonetDBDriver", def=function(drv, ...)
invisible(TRUE))
setMethod("dbGetInfo", "MonetDBDriver", def=function(dbObj, ...)
list(name="MonetDBDriver",
@@ -91,6 +88,11 @@ setMethod("dbConnect", "MonetDBDriver",
embedded <- substring(dbname, 13, nchar(dbname))
}
+ if (inherits(drv, "MonetDBEmbeddedDriver")) {
+ if (missing(dbname)) embedded <- tempdir()
+ else embedded <- dbname
+ }
+
if (embedded != FALSE) {
if (!require("MonetDBLite", character.only=T)) {
stop("MonetDBLite package required for embedded mode")
diff --git a/tools/embedded/Tests/dbi.R b/tools/embedded/Tests/dbi.R
--- a/tools/embedded/Tests/dbi.R
+++ b/tools/embedded/Tests/dbi.R
@@ -13,7 +13,7 @@ tsize <- function(conn, tname)
as.integer(dbGetQuery(conn, paste0("SELECT COUNT(*) FROM ",tname))[[1]])
test_that("db starts up and accepts queries", {
- con <<- dbConnect(MonetDB.R::MonetDB.R(), embedded=tempdir())
+ con <<- dbConnect(MonetDBLite(), tempdir())
expect_is(con, "MonetDBEmbeddedConnection")
expect_true(dbIsValid(con))
res <- dbGetQuery(con, "SELECT 42")
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list