replace outputpath with outputfolder for consistency. update documentation.
This commit is contained in:
parent
b8425920ff
commit
de1c577b6b
|
@ -42,16 +42,16 @@ executeDdl <- function(connectionDetails,
|
||||||
executeForeignKey = TRUE,
|
executeForeignKey = TRUE,
|
||||||
...) {
|
...) {
|
||||||
|
|
||||||
outputpath <- tempdir(check = TRUE)
|
outputfolder <- tempdir(check = TRUE)
|
||||||
|
|
||||||
|
|
||||||
if(executeDdl) {
|
if(executeDdl) {
|
||||||
filename <- writeDdl(targetDialect = connectionDetails$dbms,
|
filename <- writeDdl(targetDialect = connectionDetails$dbms,
|
||||||
cdmVersion = cdmVersion,
|
cdmVersion = cdmVersion,
|
||||||
cdmDatabaseSchema = cdmDatabaseSchema,
|
cdmDatabaseSchema = cdmDatabaseSchema,
|
||||||
outputpath = outputpath)
|
outputfolder = outputfolder)
|
||||||
|
|
||||||
sql <- readr::read_file(file.path(outputpath, filename))
|
sql <- readr::read_file(file.path(outputfolder, filename))
|
||||||
} else {
|
} else {
|
||||||
sql <- ""
|
sql <- ""
|
||||||
}
|
}
|
||||||
|
@ -60,18 +60,18 @@ executeDdl <- function(connectionDetails,
|
||||||
filename <- writePrimaryKeys(targetDialect = connectionDetails$dbms,
|
filename <- writePrimaryKeys(targetDialect = connectionDetails$dbms,
|
||||||
cdmVersion = cdmVersion,
|
cdmVersion = cdmVersion,
|
||||||
cdmDatabaseSchema = cdmDatabaseSchema,
|
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) {
|
if(executeForeignKey) {
|
||||||
filename <- writeForeignKeys(targetDialect = connectionDetails$dbms,
|
filename <- writeForeignKeys(targetDialect = connectionDetails$dbms,
|
||||||
cdmVersion = cdmVersion,
|
cdmVersion = cdmVersion,
|
||||||
cdmDatabaseSchema = cdmDatabaseSchema,
|
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)
|
con <- DatabaseConnector::connect(connectionDetails = connectionDetails)
|
||||||
|
|
|
@ -5,15 +5,20 @@
|
||||||
\title{Create OMOP CDM SQL files}
|
\title{Create OMOP CDM SQL files}
|
||||||
\usage{
|
\usage{
|
||||||
buildRelease(
|
buildRelease(
|
||||||
cdmVersion = listSupportedVersions(),
|
cdmVersions = listSupportedVersions(),
|
||||||
targetDialect = listSupportedDialects()
|
targetDialects = listSupportedDialects(),
|
||||||
|
outputfolder = file.path(getwd(), "ddl")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\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.}
|
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{
|
\description{
|
||||||
Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion
|
Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
buildReleaseZip(
|
buildReleaseZip(
|
||||||
cdmVersion,
|
cdmVersion,
|
||||||
targetDialect = listSupportedDialects(),
|
targetDialect = listSupportedDialects(),
|
||||||
outputfolder = "output"
|
outputfolder = file.path(getwd(), "ddl")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
|
|
|
@ -10,28 +10,28 @@
|
||||||
writeDdl(
|
writeDdl(
|
||||||
targetDialect,
|
targetDialect,
|
||||||
cdmVersion,
|
cdmVersion,
|
||||||
outputpath,
|
outputfolder,
|
||||||
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
||||||
)
|
)
|
||||||
|
|
||||||
writePrimaryKeys(
|
writePrimaryKeys(
|
||||||
targetDialect,
|
targetDialect,
|
||||||
cdmVersion,
|
cdmVersion,
|
||||||
outputpath,
|
outputfolder,
|
||||||
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
||||||
)
|
)
|
||||||
|
|
||||||
writeForeignKeys(
|
writeForeignKeys(
|
||||||
targetDialect,
|
targetDialect,
|
||||||
cdmVersion,
|
cdmVersion,
|
||||||
outputpath,
|
outputfolder,
|
||||||
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
||||||
)
|
)
|
||||||
|
|
||||||
writeIndex(
|
writeIndex(
|
||||||
targetDialect,
|
targetDialect,
|
||||||
cdmVersion,
|
cdmVersion,
|
||||||
outputpath,
|
outputfolder,
|
||||||
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
cdmDatabaseSchema = "@cdmDatabaseSchema"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ writeIndex(
|
||||||
|
|
||||||
\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4}
|
\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.
|
\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"}
|
Defaults to "@cdmDatabaseSchema"}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
test_that("writeDdl works", {
|
test_that("writeDdl works", {
|
||||||
|
|
||||||
outputpath <- tempdir(TRUE)
|
outputfolder <- tempdir(TRUE)
|
||||||
filename <- writeDdl(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath)
|
filename <- writeDdl(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder)
|
||||||
|
|
||||||
expect_true(file.exists(file.path(outputpath, filename)))
|
expect_true(file.exists(file.path(outputfolder, filename)))
|
||||||
sql <- readr::read_file(file.path(outputpath, filename))
|
sql <- readr::read_file(file.path(outputfolder, filename))
|
||||||
|
|
||||||
expect_type(sql, "character")
|
expect_type(sql, "character")
|
||||||
expect_gt(nchar(sql), 10)
|
expect_gt(nchar(sql), 10)
|
||||||
|
@ -13,11 +13,11 @@ test_that("writeDdl works", {
|
||||||
|
|
||||||
test_that("writePrimaryKeys works", {
|
test_that("writePrimaryKeys works", {
|
||||||
|
|
||||||
outputpath <- tempdir(TRUE)
|
outputfolder <- tempdir(TRUE)
|
||||||
filename <- writePrimaryKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath)
|
filename <- writePrimaryKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder)
|
||||||
|
|
||||||
expect_true(file.exists(file.path(outputpath, filename)))
|
expect_true(file.exists(file.path(outputfolder, filename)))
|
||||||
sql <- readr::read_file(file.path(outputpath, filename))
|
sql <- readr::read_file(file.path(outputfolder, filename))
|
||||||
|
|
||||||
expect_type(sql, "character")
|
expect_type(sql, "character")
|
||||||
expect_gt(nchar(sql), 10)
|
expect_gt(nchar(sql), 10)
|
||||||
|
@ -26,11 +26,11 @@ test_that("writePrimaryKeys works", {
|
||||||
|
|
||||||
test_that("writeForeignKeys works", {
|
test_that("writeForeignKeys works", {
|
||||||
|
|
||||||
outputpath <- tempdir(TRUE)
|
outputfolder <- tempdir(TRUE)
|
||||||
filename <- writeForeignKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath)
|
filename <- writeForeignKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder)
|
||||||
|
|
||||||
expect_true(file.exists(file.path(outputpath, filename)))
|
expect_true(file.exists(file.path(outputfolder, filename)))
|
||||||
sql <- readr::read_file(file.path(outputpath, filename))
|
sql <- readr::read_file(file.path(outputfolder, filename))
|
||||||
|
|
||||||
expect_type(sql, "character")
|
expect_type(sql, "character")
|
||||||
expect_gt(nchar(sql), 10)
|
expect_gt(nchar(sql), 10)
|
||||||
|
@ -39,11 +39,11 @@ test_that("writeForeignKeys works", {
|
||||||
|
|
||||||
test_that("writeIndex works", {
|
test_that("writeIndex works", {
|
||||||
|
|
||||||
outputpath <- tempdir(TRUE)
|
outputfolder <- tempdir(TRUE)
|
||||||
filename <- writeIndex(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath)
|
filename <- writeIndex(targetDialect = "postgresql", cdmVersion = "5.4", outputfolder = outputfolder)
|
||||||
|
|
||||||
expect_true(file.exists(file.path(outputpath, filename)))
|
expect_true(file.exists(file.path(outputfolder, filename)))
|
||||||
sql <- readr::read_file(file.path(outputpath, filename))
|
sql <- readr::read_file(file.path(outputfolder, filename))
|
||||||
|
|
||||||
expect_type(sql, "character")
|
expect_type(sql, "character")
|
||||||
expect_gt(nchar(sql), 10)
|
expect_gt(nchar(sql), 10)
|
||||||
|
|
Loading…
Reference in New Issue