Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added schema support for SQLite connections #67

Merged
merged 22 commits into from
Nov 27, 2023
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
42f7401
feat: Added schema support for SQLite connections
Nov 8, 2023
459c6bf
chore: Require dbplyr >= 2.4.0
Nov 13, 2023
b138653
fix(test-update_snapshot): Specify df argument in `dplyr::copy_to`
Nov 13, 2023
1f681d0
chore: linting
Nov 13, 2023
a30472d
chore: Add entry to NEWS.md
Nov 13, 2023
139ef5b
feat(sqlite_schema): Rework `get_schema` and `table_exists` to S3 met…
Nov 21, 2023
708fb2c
fix(sqlite_schema): Exclude temporary SQLite tables from `get_tables`
Nov 21, 2023
605861c
feat: Allow `id` to fallback to table name with "."
Nov 21, 2023
bd0691c
fix(get_tables): Correctly handle temporary tables in SQLite
Nov 21, 2023
a795376
fix(table_exists): Add bindings and unite man pages
Nov 21, 2023
0ab9874
chore: Conditionally skip example parts
Nov 21, 2023
7333856
chore: Linting
Nov 21, 2023
0f11308
fix(table_exists): Remove undesirable conversion to `DBI::Id`
Nov 21, 2023
e9a4e04
test(table_exists): Rework ambiguity test for SQLite
Nov 21, 2023
751b412
fix: Correctly handle missing schema in `table_exists.SQLiteConnection`
Nov 21, 2023
96167d9
fix(table_exists.SQLiteConnection): Prepare `db_table_id` for loose(r…
Nov 21, 2023
9c6997a
chore: Remove redundant logic in examples
Nov 23, 2023
e61090c
chore: Add `get_schema.tbl_dbi` and `get_schema.Id`
Nov 23, 2023
6c8ef73
fix: Subset `exact_match` instead of `tables`
Nov 23, 2023
da2888b
test: Add test for `allow_table_only`
Nov 23, 2023
93c9655
test(id): re-added test for `id` on `DBIConnection`s
Nov 23, 2023
071a224
docs: Fix `create_logs_if_missing` example failing check
Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: Conditionally skip example parts
Marcus Munch Grünewald authored and Marcus Munch Grünewald committed Nov 21, 2023
commit 0ab9874fa1bb3b10f39ae28a0c1463c14e8abb1c
4 changes: 3 additions & 1 deletion R/create_table.R
Original file line number Diff line number Diff line change
@@ -100,7 +100,9 @@ methods::setMethod("getTableSignature", "NULL", function(.data, conn) {
#' @examples
#' conn <- get_connection(drv = RSQLite::SQLite())
#'
#' create_logs_if_missing("test.logs", conn)
#' if (schema_exists(conn, "test")) {
marcusmunch marked this conversation as resolved.
Show resolved Hide resolved
#' create_logs_if_missing("test.logs", conn)
#' }
#'
#' close_connection(conn)
#' @export
25 changes: 14 additions & 11 deletions R/db_manipulating_functions.R
Original file line number Diff line number Diff line change
@@ -133,19 +133,22 @@ unite.tbl_dbi <- function(data, col, ..., sep = "_", remove = TRUE, na.rm = FALS
#' @examples
#' conn <- get_connection(drv = RSQLite::SQLite())
#'
#' t1 <- data.frame(key = c("A", "A", "B"),
#' obs_1 = c(1, 2, 2),
#' valid_from = as.Date(c("2021-01-01", "2021-02-01", "2021-01-01")),
#' valid_until = as.Date(c("2021-02-01", "2021-03-01", NA)))
#' t1 <- dplyr::copy_to(conn, t1, id("test.SCDB_tmp1", conn), overwrite = TRUE, temporary = FALSE)
#'
#' t2 <- data.frame(key = c("A", "B"),
#' obs_2 = c("a", "b"),
#' valid_from = as.Date(c("2021-01-01", "2021-01-01")),
#' valid_until = as.Date(c("2021-04-01", NA)))
#' t2 <- dplyr::copy_to(conn, t2, id("test.SCDB_tmp2", conn), overwrite = TRUE, temporary = FALSE)
#' if (schema_exists(conn, "test")) {
#' t1 <- data.frame(key = c("A", "A", "B"),
#' obs_1 = c(1, 2, 2),
#' valid_from = as.Date(c("2021-01-01", "2021-02-01", "2021-01-01")),
#' valid_until = as.Date(c("2021-02-01", "2021-03-01", NA)))
#' t1 <- dplyr::copy_to(conn, t1, id("test.SCDB_tmp1", conn), overwrite = TRUE, temporary = FALSE)
#'
#' interlace_sql(list(t1, t2), by = "key")
#' t2 <- data.frame(key = c("A", "B"),
#' obs_2 = c("a", "b"),
#' valid_from = as.Date(c("2021-01-01", "2021-01-01")),
#' valid_until = as.Date(c("2021-04-01", NA)))
#' t2 <- dplyr::copy_to(conn, t2, id("test.SCDB_tmp2", conn), overwrite = TRUE, temporary = FALSE)
#'
#' interlace_sql(list(t1, t2), by = "key")
#' }
#'
#' close_connection(conn)
#' @return The combination of input queries with a single, interlaced
4 changes: 3 additions & 1 deletion R/get_table.R
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@
#' dplyr::copy_to(conn, mtcars, name = "mtcars")
#'
#' get_table(conn)
#' get_table(conn, "mtcars")
#' if (table_exists(conn, "mtcars")) {
marcusmunch marked this conversation as resolved.
Show resolved Hide resolved
#' get_table(conn, "mtcars")
#' }
#'
#' close_connection(conn)
#' @importFrom rlang .data
@@ -258,7 +260,7 @@
dplyr::filter(.data$table_str == !!target_str) |>
dplyr::select(!"table_str")

if (nrow(matches) <= 1){

Check warning on line 263 in R/get_table.R

GitHub Actions / lint

file=R/get_table.R,line=263,col=26,[brace_linter] There should be a space before an opening curly brace.

Check warning on line 263 in R/get_table.R

GitHub Actions / lint

file=R/get_table.R,line=263,col=26,[paren_body_linter] There should be a space between a right parenthesis and a body expression.
return(nrow(matches) == 1)
}

4 changes: 3 additions & 1 deletion man/create_logs_if_missing.Rd

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

4 changes: 3 additions & 1 deletion man/get_schema.Rd

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

4 changes: 3 additions & 1 deletion man/get_table.Rd

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

25 changes: 14 additions & 11 deletions man/interlace_sql.Rd

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

Loading