Changeset: c6b8e79b087d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c6b8e79b087d
Modified Files:
clients/R/MonetDB.R/NEWS
clients/R/MonetDB.R/R/dbi.R
clients/R/Tests/dbi.R
clients/R/Tests/dbi.stable.err
clients/R/Tests/dbi.stable.out
Branch: embedded
Log Message:
R Connector, dealing with file names passed to dbWriteTable, Bug 3869
diffs (94 lines):
diff --git a/clients/R/MonetDB.R/NEWS b/clients/R/MonetDB.R/NEWS
--- a/clients/R/MonetDB.R/NEWS
+++ b/clients/R/MonetDB.R/NEWS
@@ -24,7 +24,7 @@ 1.0.0
- Support for monetdblite:/some/path URLs in dbConnect()
- Fixed an off-by-one error in type conversion (Thanks, Kirill)
- Not force-killing mserver when calling monetdb.server.stop on windows and
wait support
-
+- dbWriteTable now invokes monetdb.read.csv when called with a character
vector as value argument
0.9.7
- Fixed crash on Windows (Sorry, everyone)
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
@@ -429,6 +429,11 @@ quoteIfNeeded <- function(conn, x, warn=
setMethod("dbWriteTable", "MonetDBConnection", def=function(conn, name, value,
overwrite=FALSE,
append=FALSE, csvdump=FALSE, transaction=TRUE,...) {
+ if (is.character(value)) {
+ message("Treating character vector parameter as file name(s) for
monetdb.read.csv()")
+ monetdb.read.csv(conn=conn, files=value, tablename=name, create=!append,
...)
+ return(invisible(TRUE))
+ }
if (is.vector(value) && !is.list(value)) value <- data.frame(x=value,
stringsAsFactors=F)
if (length(value)<1) stop("value must have at least one column")
if (is.null(names(value))) names(value) <- paste("V", 1:length(value),
sep='')
diff --git a/clients/R/Tests/dbi.R b/clients/R/Tests/dbi.R
--- a/clients/R/Tests/dbi.R
+++ b/clients/R/Tests/dbi.R
@@ -93,23 +93,36 @@ stopifnot(identical(dbExistsTable(con,tn
tf <- tempfile()
write.table(iris,tf,sep=",",row.names=FALSE)
tname2 <- "Need to quote this table name"
+tname3 <- "othermethod"
monetdb.read.csv(con,tf,tname)
monetdb.read.csv(con,tf,tname2)
+dbWriteTable(con, tname3, tf)
+
###
dbListTables(con)
unlink(tf)
stopifnot(identical(dbExistsTable(con,tname),TRUE))
stopifnot(identical(dbExistsTable(con,tname2),TRUE))
+stopifnot(identical(dbExistsTable(con,tname3),TRUE))
+
iris3 <- dbReadTable(con,tname)
iris4 <- dbReadTable(con,tname2)
+iris5 <- dbReadTable(con,tname3)
stopifnot(identical(dim(iris),dim(iris3)))
stopifnot(identical(dim(iris),dim(iris4)))
+stopifnot(identical(dim(iris),dim(iris5)))
stopifnot(identical(dbListFields(con,tname),names(iris)))
stopifnot(identical(dbListFields(con,tname2),names(iris)))
+stopifnot(identical(dbListFields(con,tname3),names(iris)))
+
dbRemoveTable(con,tname)
dbRemoveTable(con,tname2)
+dbRemoveTable(con,tname3)
+
stopifnot(identical(dbExistsTable(con,tname),FALSE))
+stopifnot(identical(dbExistsTable(con,tname2),FALSE))
+stopifnot(identical(dbExistsTable(con,tname3),FALSE))
# test dbWriteTable
tsize <- function(conn,tname)
diff --git a/clients/R/Tests/dbi.stable.err b/clients/R/Tests/dbi.stable.err
--- a/clients/R/Tests/dbi.stable.err
+++ b/clients/R/Tests/dbi.stable.err
@@ -34,6 +34,9 @@ Identifier(s) "Sepal.Length", "Sepal.Wid
Identifier(s) "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width",
"Species" contain uppercase or reserved SQL characters and need(s) to be quoted
in queries.
Identifier(s) "Need to quote this table name" contain uppercase or reserved
SQL characters and need(s) to be quoted in queries.
Identifier(s) "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width",
"Species" contain uppercase or reserved SQL characters and need(s) to be quoted
in queries.
+Treating character vector parameter as file name(s) for monetdb.read.csv()
+Identifier(s) "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width",
"Species" contain uppercase or reserved SQL characters and need(s) to be quoted
in queries.
+Identifier(s) "Need to quote this table name" contain uppercase or reserved
SQL characters and need(s) to be quoted in queries.
Identifier(s) "Need to quote this table name" contain uppercase or reserved
SQL characters and need(s) to be quoted in queries.
Identifier(s) "Need to quote this table name" contain uppercase or reserved
SQL characters and need(s) to be quoted in queries.
Identifier(s) "Need to quote this table name" contain uppercase or reserved
SQL characters and need(s) to be quoted in queries.
diff --git a/clients/R/Tests/dbi.stable.out b/clients/R/Tests/dbi.stable.out
--- a/clients/R/Tests/dbi.stable.out
+++ b/clients/R/Tests/dbi.stable.out
@@ -52,7 +52,10 @@ Ready.
[1] TRUE
[1] TRUE
[1] TRUE
+[1] TRUE
[1] "\"Need to quote this table name\"" "monetdbtest"
+[3] "othermethod"
+[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list