Skip to content

Commit

Permalink
Reorganinze package structure
Browse files Browse the repository at this point in the history
Have one file per exported function
  • Loading branch information
quartin committed Aug 13, 2018
1 parent 37ff0d9 commit 1ee9209
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
10 changes: 10 additions & 0 deletions R/as_sql_array.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#' @export
#' @title Transform a vector into a SQL-interpreted array.
#'
#' @param vector character vector
#' @return
#' List with a single string that's interpreted as a SQL array to interpolate in a query.
as_sql_array <- function(vector) {
array <- paste0("(", paste(paste0("'", vector, "'"), collapse = ", "), ")")
list(array)
}
15 changes: 15 additions & 0 deletions R/db_table.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' @export
#' @title Create a tbl that references a schema.table in the `conn` database.
#'
#' @param conn A database connection.
#' @param schema A string with schema name.
#' @param table A string with table name.
#'
#' @return
#' A reference to a database table.
#'
#' @importFrom dbplyr in_schema
#' @importFrom dplyr tbl
db_table <- function(conn, schema, table) {
tbl(conn, in_schema(schema, table))
}
27 changes: 0 additions & 27 deletions R/dbutils.R → R/fetch_db.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
#' @export
#' @title Create a tbl that references a schema.table in the `conn` database.
#'
#' @param conn A database connection.
#' @param schema A string with schema name.
#' @param table A string with table name.
#'
#' @return
#' A reference to a database table.
#'
#' @importFrom dbplyr in_schema
#' @importFrom dplyr tbl
db_table <- function(conn, schema, table) {
tbl(conn, in_schema(schema, table))
}

#' @export
#' @title Fetch data from db
#'
Expand Down Expand Up @@ -43,14 +27,3 @@ fetch_db <- function(conn, path, ...) {
stop(e)
})
}

#' @export
#' @title Transform a vector into a SQL-interpreted array.
#'
#' @param vector character vector
#' @return
#' List with a single string that's interpreted as a SQL array to interpolate in a query.
as_sql_array <- function(vector) {
array <- paste0("(", paste(paste0("'", vector, "'"), collapse = ", "), ")")
list(array)
}
5 changes: 4 additions & 1 deletion man/as_sql_array.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/db_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ee9209

Please sign in to comment.