Skip to content

Commit

Permalink
Merge pull request #461 from r-dbi/f-exists-table
Browse files Browse the repository at this point in the history
chore: Use `Id` in `exists_table()`
  • Loading branch information
aviator-app[bot] authored Apr 1, 2024
2 parents bb945a1 + c07c658 commit e93306e
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 e93306e

Please sign in to comment.