Skip to content

Commit

Permalink
Merge pull request #152 from ssi-dk/fix/get_table-robust
Browse files Browse the repository at this point in the history
Simplify `get_table()` checks
  • Loading branch information
RasmusSkytte authored Sep 26, 2024
2 parents ee41a44 + b407bf3 commit 587a839
Show file tree
Hide file tree
Showing 3 changed files with 314 additions and 315 deletions.
1 change: 1 addition & 0 deletions .github/workflows/all-workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:

# code-coverage creates data bases for the tests. Here you can specify the schemas you need for the workflow
schemas: test,test.one
check_postgres_logs: false
secrets: inherit
11 changes: 5 additions & 6 deletions R/get_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ get_table <- function(conn, db_table = NULL, slice_ts = NA, include_slice_info =
# Ensure id is fully qualified
db_table_id <- id(db_table, conn = conn)

# Ensure existence of table
if (!table_exists(conn, db_table_id)) {
rlang::abort(glue::glue("Table {as.character(db_table_id)} could not be found!"))
}

# Look-up table in database
q <- dplyr::tbl(conn, db_table_id)
tryCatch({
q <- dplyr::tbl(conn, db_table_id)
}, error = function(e) {
stop(glue::glue("Table {as.character(db_table_id)} could not be found!"))
})

# Check whether data is historical
if (is.historical(q) && !is.null(slice_ts)) {
Expand Down
Loading

0 comments on commit 587a839

Please sign in to comment.