From de1c577b6bf164c1151dadeed07df3853ade52af Mon Sep 17 00:00:00 2001 From: Adam Black Date: Fri, 20 Aug 2021 11:25:10 -0400 Subject: [PATCH] replace outputpath with outputfolder for consistency. update documentation. --- R/executeDdl.R | 14 +++++++------- man/buildRelease.Rd | 13 +++++++++---- man/buildReleaseZip.Rd | 2 +- man/writeDdl.Rd | 10 +++++----- tests/testthat/test-writeDdl.R | 32 ++++++++++++++++---------------- 5 files changed, 38 insertions(+), 33 deletions(-) diff --git a/R/executeDdl.R b/R/executeDdl.R index ed5e010..3c1d3ff 100644 --- a/R/executeDdl.R +++ b/R/executeDdl.R @@ -42,16 +42,16 @@ executeDdl <- function(connectionDetails, executeForeignKey = TRUE, ...) { - outputpath <- tempdir(check = TRUE) + outputfolder <- tempdir(check = TRUE) if(executeDdl) { filename <- writeDdl(targetDialect = connectionDetails$dbms, cdmVersion = cdmVersion, cdmDatabaseSchema = cdmDatabaseSchema, - outputpath = outputpath) + outputfolder = outputfolder) - sql <- readr::read_file(file.path(outputpath, filename)) + sql <- readr::read_file(file.path(outputfolder, filename)) } else { sql <- "" } @@ -60,18 +60,18 @@ executeDdl <- function(connectionDetails, filename <- writePrimaryKeys(targetDialect = connectionDetails$dbms, cdmVersion = cdmVersion, cdmDatabaseSchema = cdmDatabaseSchema, - outputpath = outputpath) + outputfolder = outputfolder) - sql <- paste(sql, readr::read_file(file.path(outputpath, filename)), sep = "\n") + sql <- paste(sql, readr::read_file(file.path(outputfolder, filename)), sep = "\n") } if(executeForeignKey) { filename <- writeForeignKeys(targetDialect = connectionDetails$dbms, cdmVersion = cdmVersion, cdmDatabaseSchema = cdmDatabaseSchema, - outputpath = outputpath) + outputfolder = outputfolder) - sql <- paste(sql, readr::read_file(file.path(outputpath, filename)), sep = "\n") + sql <- paste(sql, readr::read_file(file.path(outputfolder, filename)), sep = "\n") } con <- DatabaseConnector::connect(connectionDetails = connectionDetails) diff --git a/man/buildRelease.Rd b/man/buildRelease.Rd index e07fec0..2ebb36d 100644 --- a/man/buildRelease.Rd +++ b/man/buildRelease.Rd @@ -5,15 +5,20 @@ \title{Create OMOP CDM SQL files} \usage{ buildRelease( - cdmVersion = listSupportedVersions(), - targetDialect = listSupportedDialects() + cdmVersions = listSupportedVersions(), + targetDialects = listSupportedDialects(), + outputfolder = file.path(getwd(), "ddl") ) } \arguments{ -\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4. +\item{cdmVersions}{The versions of the CDM you are creating, e.g. 5.3, 5.4. Defaults to all supported CDM versions.} -\item{targetDialect}{The target dialect} +\item{targetDialects}{A character vector of target dialects. +Defaults to all supported dialects.} + +\item{outputfolder}{The base folder where the SQL files will be written. +Subfolders will be created for each cdmVersion and targetDialect.} } \description{ Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion diff --git a/man/buildReleaseZip.Rd b/man/buildReleaseZip.Rd index 95e6f55..1f204c5 100644 --- a/man/buildReleaseZip.Rd +++ b/man/buildReleaseZip.Rd @@ -7,7 +7,7 @@ buildReleaseZip( cdmVersion, targetDialect = listSupportedDialects(), - outputfolder = "output" + outputfolder = file.path(getwd(), "ddl") ) } \arguments{ diff --git a/man/writeDdl.Rd b/man/writeDdl.Rd index c245499..b5b94da 100644 --- a/man/writeDdl.Rd +++ b/man/writeDdl.Rd @@ -10,28 +10,28 @@ writeDdl( targetDialect, cdmVersion, - outputpath, + outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema" ) writePrimaryKeys( targetDialect, cdmVersion, - outputpath, + outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema" ) writeForeignKeys( targetDialect, cdmVersion, - outputpath, + outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema" ) writeIndex( targetDialect, cdmVersion, - outputpath, + outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema" ) } @@ -40,7 +40,7 @@ writeIndex( \item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4} -\item{outputpath}{The directory or folder where the SQL file should be saved.} +\item{outputfolder}{The directory or folder where the SQL file should be saved.} \item{cdmDatabaseSchema}{The schema of the CDM instance where the DDL will be run. For example, this would be "ohdsi.dbo" when testing on sql server. Defaults to "@cdmDatabaseSchema"} diff --git a/tests/testthat/test-writeDdl.R b/tests/testthat/test-writeDdl.R index 1c95f2b..91c8604 100644 --- a/tests/testthat/test-writeDdl.R +++ b/tests/testthat/test-writeDdl.R @@ -1,10 +1,10 @@ test_that("writeDdl works", { - outputpath <- tempdir(TRUE) - filename <- writeDdl(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + outputfolder <- tempdir(TRUE) + filename <- writeDdl(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder) - expect_true(file.exists(file.path(outputpath, filename))) - sql <- readr::read_file(file.path(outputpath, filename)) + expect_true(file.exists(file.path(outputfolder, filename))) + sql <- readr::read_file(file.path(outputfolder, filename)) expect_type(sql, "character") expect_gt(nchar(sql), 10) @@ -13,11 +13,11 @@ test_that("writeDdl works", { test_that("writePrimaryKeys works", { - outputpath <- tempdir(TRUE) - filename <- writePrimaryKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + outputfolder <- tempdir(TRUE) + filename <- writePrimaryKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder) - expect_true(file.exists(file.path(outputpath, filename))) - sql <- readr::read_file(file.path(outputpath, filename)) + expect_true(file.exists(file.path(outputfolder, filename))) + sql <- readr::read_file(file.path(outputfolder, filename)) expect_type(sql, "character") expect_gt(nchar(sql), 10) @@ -26,11 +26,11 @@ test_that("writePrimaryKeys works", { test_that("writeForeignKeys works", { - outputpath <- tempdir(TRUE) - filename <- writeForeignKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + outputfolder <- tempdir(TRUE) + filename <- writeForeignKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder) - expect_true(file.exists(file.path(outputpath, filename))) - sql <- readr::read_file(file.path(outputpath, filename)) + expect_true(file.exists(file.path(outputfolder, filename))) + sql <- readr::read_file(file.path(outputfolder, filename)) expect_type(sql, "character") expect_gt(nchar(sql), 10) @@ -39,11 +39,11 @@ test_that("writeForeignKeys works", { test_that("writeIndex works", { - outputpath <- tempdir(TRUE) - filename <- writeIndex(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + outputfolder <- tempdir(TRUE) + filename <- writeIndex(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder) - expect_true(file.exists(file.path(outputpath, filename))) - sql <- readr::read_file(file.path(outputpath, filename)) + expect_true(file.exists(file.path(outputfolder, filename))) + sql <- readr::read_file(file.path(outputfolder, filename)) expect_type(sql, "character") expect_gt(nchar(sql), 10)