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

chore: Use Id in exists_table() #461

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion R/dbExistsTable_PqConnection_Id.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @rdname postgres-tables
#' @usage NULL
dbExistsTable_PqConnection_Id <- function(conn, name, ...) {
exists_table(conn, id = name@name)
exists_table(conn, id = name)
}

#' @rdname postgres-tables
Expand Down
2 changes: 1 addition & 1 deletion R/dbExistsTable_PqConnection_character.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dbExistsTable_PqConnection_character <- function(conn, name, ...) {
name <- dbQuoteIdentifier(conn, name)

# Convert to identifier
id <- dbUnquoteIdentifier(conn, name)[[1]]@name
id <- dbUnquoteIdentifier(conn, name)[[1]]
exists_table(conn, id)
}

Expand Down
4 changes: 3 additions & 1 deletion R/tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ db_append_table <- function(conn, name, value, copy, warn) {
}

exists_table <- function(conn, id) {
name <- id@name

query <- paste0(
"SELECT COUNT(*) FROM ",
find_table(conn, id)
find_table(conn, name)
)

dbGetQuery(conn, query)[[1]] >= 1
Expand Down
Loading