-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Id method for dbExistsTable to address issue #498
- Loading branch information
1 parent
919a5cf
commit da0771e
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' @rdname SQLiteConnection-class | ||
#' @usage NULL | ||
dbExistsTable_SQLiteConnection_Id <- function(conn, name, ...) { | ||
stopifnot(is(name, "Id")) | ||
|
||
id <- as.list(dbUnquoteIdentifier(conn, dbQuoteIdentifier(conn, name))[[1]]@name) | ||
schema <- id$schema | ||
table <- id$table | ||
|
||
if (!is.null(schema)) { | ||
schemas <- dbGetQuery(conn, "SELECT name FROM pragma_database_list;")$name | ||
|
||
if (!(schema %in% schemas)) { | ||
return(FALSE) | ||
} | ||
} | ||
|
||
sql <- sqliteListTablesQuery(conn, schema, SQL("$name")) | ||
rs <- dbSendQuery(conn, sql) | ||
dbBind(rs, list(name = tolower(table))) | ||
on.exit(dbClearResult(rs), add = TRUE) | ||
|
||
nrow(dbFetch(rs, 1L)) > 0 | ||
} | ||
#' @rdname SQLiteConnection-class | ||
#' @export | ||
setMethod("dbExistsTable", c("SQLiteConnection", "Id"), dbExistsTable_SQLiteConnection_Id) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.