From ec83c9ce54bd00af28c483dbaad0e970fbba20a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 20 Apr 2021 10:18:06 +0200 Subject: [PATCH] Revert "Merge pull request #363 from r-dbi/edwindj-main" - Remove RStudio Connection pane support due to problems reported by users. This reverts commit 4c46b695ffa5211dae5f9f098e659ba99c6dd40e, reversing changes made to 91322136a1181bf178942e4bc1ec1feb9079e04e. Reverts changes from #352 and #363, CC @edwindj. --- DESCRIPTION | 1 - R/connect.R | 7 -- R/rstudioConnections.R | 155 ------------------------------ R/table.R | 12 --- inst/icons/sqlite.png | Bin 10379 -> 0 bytes inst/rstudio/connections.dcf | 3 - inst/rstudio/connections/SQLite.R | 9 -- 7 files changed, 187 deletions(-) delete mode 100644 R/rstudioConnections.R delete mode 100644 inst/icons/sqlite.png delete mode 100644 inst/rstudio/connections.dcf delete mode 100644 inst/rstudio/connections/SQLite.R diff --git a/DESCRIPTION b/DESCRIPTION index 5dfbe3e89..1cf0bfa1f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -79,7 +79,6 @@ Collate: 'query.R' 'regularExpressions.R' 'rownames.R' - 'rstudioConnections.R' 'table.R' 'transactions.R' 'utils.R' diff --git a/R/connect.R b/R/connect.R index 27a2ca800..2b7214b5f 100644 --- a/R/connect.R +++ b/R/connect.R @@ -203,9 +203,6 @@ setMethod("dbConnect", "SQLiteDriver", } ) - # rstudio connections tab - on_connection_opened(conn) - conn } ) @@ -258,9 +255,5 @@ setMethod("dbConnect", "SQLiteConnection", function(drv, ...) { #' @rdname SQLite setMethod("dbDisconnect", "SQLiteConnection", function(conn, ...) { connection_release(conn@ptr) - - # rstudio connections tab - on_connection_closed(conn) - invisible(TRUE) }) diff --git a/R/rstudioConnections.R b/R/rstudioConnections.R deleted file mode 100644 index 4a0a8ba3a..000000000 --- a/R/rstudioConnections.R +++ /dev/null @@ -1,155 +0,0 @@ -# Functions used to connect to Connections Pane in Rstudio -# Implementing connections contract: https://rstudio.github.io/rstudio-extensions/connections-contract.html -sqlite_ListObjectTypes <- function(con) { - object_types <- list(table = list(contains = "data")) - - types <- dbGetQuery(con, "SELECT DISTINCT type FROM sqlite_master")[[1]] - if (any(types == "view")) { - object_types <- c(object_types, view = list(contains = "data")) - } - object_types -} - -sqlite_ListObjects <- function(con, catalog = NULL, schema = NULL, name = NULL, type = NULL, ...) { - objects <- dbGetQuery(con, "SELECT name,type FROM sqlite_master") - objects <- objects[objects$type %in% c("table", "view"), ] - objects -} - -sqlite_ListColumns <- function(con, table = NULL, view = NULL, - catalog = NULL, schema = NULL, ...) { - if (is.null(table)) { - table <- view - } - - tb <- dbGetQuery( - con, - paste("SELECT * FROM", dbQuoteIdentifier(con, table), "WHERE FALSE") - ) - - name <- names(tb) - type <- sapply(tb, class) - - data.frame( - name = name, - type = type, - stringsAsFactors = FALSE - ) -} - -sqlite_PreviewObject <- function(con, rowLimit, table = NULL, view = NULL, ...) { - # extract object name from arguments - name <- if (is.null(table)) view else table - dbGetQuery(con, paste("SELECT * FROM", dbQuoteIdentifier(con, name)), n = rowLimit) -} - -sqlite_ConnectionIcon <- function(con) { - system.file("icons/sqlite.png", package = "RSQLite") -} - -sqlite_ConnectionActions <- function(con) { - actions <- list() - actions <- c(actions, list( - Help = list( - icon = "", - callback = function() { - utils::browseURL("https://rsqlite.r-dbi.org/") - } - ) - )) - - actions -} - - -get_host <- function(con) { - if (con@dbname == "") { - return("") - } - paste0("<", con@dbname, ">") -} - -##### Functions that trigger update in Rstudio Connections tab - -on_connection_opened <- function(con) { - observer <- getOption("connectionObserver") - if (is.null(observer)) { - return(invisible(NULL)) - } - - code <- paste0( - "library(DBI) -con <- dbConnect(RSQLite::SQLite(), dbname=\"", con@dbname, "\") -" - ) - icon <- sqlite_ConnectionIcon(con) - - host <- get_host(con) - - # let observer know that connection has opened - observer$connectionOpened( - # connection type - type = "RSQLite", - - # name displayed in connection pane (to be improved) - displayName = paste0( - "SQLite ", - host, - if (con@dbname == "") " (temporary)" - ), - host = host, - icon = icon, - - # connection code - connectCode = code, - - # disconnection code - disconnect = function() { - dbDisconnect(con, shutdown = TRUE) - }, - listObjectTypes = function() { - sqlite_ListObjectTypes(con) - }, - - # table enumeration code - listObjects = function(...) { - sqlite_ListObjects(con, ...) - }, - - # column enumeration code - listColumns = function(...) { - sqlite_ListColumns(con, ...) - }, - - # table preview code - previewObject = function(rowLimit, ...) { - sqlite_PreviewObject(con, rowLimit, ...) - }, - - # other actions that can be executed on this connection - actions = sqlite_ConnectionActions(con), - - # raw connection object - connectionObject = con - ) -} - -on_connection_updated <- function(con, hint) { - observer <- getOption("connectionObserver") - if (is.null(observer)) { - return(invisible(NULL)) - } - - host <- get_host(con) - observer$connectionUpdated("RSQLite", host, hint = hint) -} - -on_connection_closed <- function(con) { - observer <- getOption("connectionObserver") - if (is.null(observer)) { - return(invisible(NULL)) - } - - host <- get_host(con) - observer$connectionClosed("RSQLite", host) -} diff --git a/R/table.R b/R/table.R index 36871025f..4505d0a29 100644 --- a/R/table.R +++ b/R/table.R @@ -129,10 +129,6 @@ setMethod("dbWriteTable", c("SQLiteConnection", "character", "data.frame"), dbCommit(conn, name = savepoint_id) on.exit(NULL) - - # rstudio connections tab - on_connection_updated(conn, paste0("Updating table '", name, "'")) - invisible(TRUE) } ) @@ -242,10 +238,6 @@ setMethod("dbWriteTable", c("SQLiteConnection", "character", "character"), dbCommit(conn, name = savepoint_id) on.exit(NULL) - - # rstudio connections tab - on_connection_updated(conn, paste0("Updating table '", name, "'")) - invisible(TRUE) } ) @@ -370,10 +362,6 @@ setMethod("dbRemoveTable", c("SQLiteConnection", "character"), } dbExecute(conn, paste0("DROP TABLE ", extra, name)) - - # rstudio connections tab - on_connection_updated(conn, paste0("Removing table '", name, "'")) - invisible(TRUE) } ) diff --git a/inst/icons/sqlite.png b/inst/icons/sqlite.png deleted file mode 100644 index c113a9fff095cf848f1e3da97e95dd13139c982c..0000000000000000000000000000000000000000 GIT binary patch literal 0 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-JxGk*}%5q-l&AQ(^=ka0iZB6`Vl2~s+D#gM1DV2VMC*WJgVp|ee!+o0Z zJ>idg9OQXIQ~#=iD&J!=>%`5oF-t&u?$0#YlpC@bMi5|aOOt#m9QJ1evx9ZHvyEzg~f;tSNBDr3~09nlGsTGE4XewQBuU)s@4$sFTw zcfoyBA|qM(g-iDInM!Ph`}ZA=-h0C~gr>H|VF<38>V=E7&kVaT=LBCS)1QWMnAXH2bv9s^UmXy0@gtmF!vn?WWwU^NWX!h$Qn*=rJm$$#ZoNzLMMO zW}bd`e(J8Xbx$Y>kcKHs@B5FeGeT#C?1nE7&p(%O?^a{{hdj<{9 diff --git a/inst/rstudio/connections.dcf b/inst/rstudio/connections.dcf deleted file mode 100644 index 0edc4ae7f..000000000 --- a/inst/rstudio/connections.dcf +++ /dev/null @@ -1,3 +0,0 @@ -Name: SQLite -HelpUrl: https://rsqlite.r-dbi.org/ -Icon: icons/sqlite.png diff --git a/inst/rstudio/connections/SQLite.R b/inst/rstudio/connections/SQLite.R deleted file mode 100644 index b4c5df7b8..000000000 --- a/inst/rstudio/connections/SQLite.R +++ /dev/null @@ -1,9 +0,0 @@ -library(RSQLite) - -con <- DBI::dbConnect(SQLite(), dbname = "${1:File name}") - -## Adding a table to the empty database -# DBI::dbWriteTable(con, "iris", iris) - -## Disconnecting... -# DBI::dbDisconnect(con)