Skip to content

Commit

Permalink
Revert "remove conn argument from list_tables()"
Browse files Browse the repository at this point in the history
LOL of course we need this once we query system catalogs
on Pq_connections but not redshift
This reverts commit d7896d0.
  • Loading branch information
dpprdan committed Dec 14, 2022
1 parent b54a868 commit 63490cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions R/dbListObjects_PqConnection_ANY.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ dbListObjects_PqConnection_ANY <- function(conn, prefix = NULL, ...) {
}
query <- paste0(
"SELECT ", null_varchar, " AS schema, table_name AS table FROM ( \n",
list_tables(order_by = "table_type, table_name"),
list_tables(conn = conn, order_by = "table_type, table_name"),
") as table_query \n",
"UNION ALL\n",
"SELECT DISTINCT table_schema AS schema, ", null_varchar, " AS table FROM ( \n",
list_tables(where_schema = "true"),
list_tables(conn = conn),
") as schema_query;"
)
} else {
Expand All @@ -38,6 +38,7 @@ dbListObjects_PqConnection_ANY <- function(conn, prefix = NULL, ...) {
query <- paste0(
"SELECT table_schema AS schema, table_name AS table FROM ( \n",
list_tables(
conn = conn,
where_schema = where_schema,
order_by = "table_type, table_name"
),
Expand Down
2 changes: 1 addition & 1 deletion R/dbListTables_PqConnection.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @rdname postgres-tables
#' @usage NULL
dbListTables_PqConnection <- function(conn, ...) {
query <- list_tables(order_by = "table_type, table_name")
query <- list_tables(conn = conn, order_by = "table_type, table_name")

dbGetQuery(conn, query)[["table_name"]]
}
Expand Down
4 changes: 2 additions & 2 deletions R/tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ db_append_table <- function(conn, name, value, copy, warn) {
nrow(value)
}

list_tables <- function(where_schema = NULL, where_table = NULL, order_by = NULL) {
list_tables <- function(conn, where_schema = NULL, where_table = NULL, order_by = NULL) {

query <- paste0(
# information_schema.table docs: https://www.postgresql.org/docs/current/infoschema-tables.html
Expand Down Expand Up @@ -161,7 +161,7 @@ exists_table <- function(conn, id) {
}
query <- paste0(
"SELECT EXISTS ( \n",
list_tables(where_schema = where_schema, where_table = where_table),
list_tables(conn, where_schema = where_schema, where_table = where_table),
")"
)
dbGetQuery(conn, query)[[1]]
Expand Down

0 comments on commit 63490cf

Please sign in to comment.