From c07c658ce2e7fd28a71f75a1687ef5f0fc494b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 1 Apr 2024 12:09:00 +0200 Subject: [PATCH] chore: Use `Id` in `exists_table()` --- R/dbExistsTable_PqConnection_Id.R | 2 +- R/dbExistsTable_PqConnection_character.R | 2 +- R/tables.R | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/R/dbExistsTable_PqConnection_Id.R b/R/dbExistsTable_PqConnection_Id.R index e1d99efb..1c4d34fb 100644 --- a/R/dbExistsTable_PqConnection_Id.R +++ b/R/dbExistsTable_PqConnection_Id.R @@ -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 diff --git a/R/dbExistsTable_PqConnection_character.R b/R/dbExistsTable_PqConnection_character.R index 01303940..74663758 100644 --- a/R/dbExistsTable_PqConnection_character.R +++ b/R/dbExistsTable_PqConnection_character.R @@ -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) } diff --git a/R/tables.R b/R/tables.R index 73f5a5c3..0cf19a23 100644 --- a/R/tables.R +++ b/R/tables.R @@ -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