I am trying to write a subclass for RJDBC::JDBCConnection
as I need custom methods to connect the dbplyr
package using the approach from dplyr#2941 (originally from here). However, I am not overwriting the *.JDBCConnection
methods but want to write methods for a subclass of JDBCConnection
.
Therefore, following the advise from this Stack Overflow question, I wrote my package which is essentially this:
### R/testclass.R ####################
#' Test class
#'
#' This extends JDBCConnection in package RJDBC
#'
#' @import RJDBC
#'
setClass("TestConnection", contains = "JDBCConnection")
### DESCRIPTION ######################
Package: test
Type: Package
Title: What the Package Does (Title Case)
Version: 0.1.0
Author: Who wrote it
Maintainer: The package maintainer <yourself@somewhere.net>
Description: More about what it does (maybe more than one line)
Use four spaces when indenting paragraphs within the Description.
License: What license is it under?
Encoding: UTF-8
LazyData: true
The class I want to extend exists, as can be checked with help("JDBCConnection-class", package = "RJDBC")
.
Calling devtools::document()
within this packages returns the following error:
Updating test documentation Loading test Error in reconcilePropertiesAndPrototype(name, slots, prototype, superClasses, : no definition was found for superclass "JDBCConnection" in the specification of class "TestConnection"
I also tried replacing @import
with @importClassesFrom
as per this SO question, but the result was the same.
How can I get document()
to run?
You also need to add
Imports: RJDBC
to your DESCRIPTION
file. See, for example, this guide:
If your package is using functions in other packages, you also need to add some lines to your DESCRIPTION file.
...
Imports is used for packages that are needed by your package but that don’t need to be loaded with library(). Packages referred to in @import or @importFrom statements in your Roxygen2 comments, or whose functions are accessed via the :: operator, should be here.
After that, your package document()
'd fine for me.