Skip to content

Commit

Permalink
chore: Use Id in exists_table()
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored and aviator-bot committed Apr 1, 2024
1 parent bb945a1 commit c07c658
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit c07c658

Please sign in to comment.