0

I'm following Hadley's guide to implement a DBI backend, which instructs me to build S4 classes that inherit from DBI classes.

From the instructions, to make the DBI classes available, it seems that I only have to list DBI as an import in the DESCRIPTION file.

However, even after doing so, I still get the error

 Error in reconcilePropertiesAndPrototype(name, slots, prototype, superClasses,  : 
  no definition was found for superclass “DBIDriver” in the specification of class “KazamDriver” 

If I explicit attach DBI with library then this problem go away, but of course one shouldn't use library in package code.

My code:

# DBI-backend.R 
setClass("KazamDriver", contains = "DBIDriver")

# DESCRIPTION
Imports:
  DBI (>= 0.3.0),
  methods
Heisenberg
  • 8,386
  • 12
  • 53
  • 102
  • Have you seen the new [`RKazam` package](https://github.com/rstats-db/RKazam) (a boilerplate DBI package) and the new [`DBItest` package](https://github.com/rstats-db/DBItest) (a test suite for DBI backends)? What DBMS are you implementing a DBI backend for? – krlmlr Jul 02 '17 at 21:31
  • Yes, I was following that package's tutorial. The bug I'm encountering turns out to be `devtools::document()` not modifying `NAMESPACE`. Therefore `DBI` is not imported via `NAMESPACE` despite my using `@import DBI`. So it's a `devtools::document()` bug, not a DBI / DBItest bug. – Heisenberg Jul 02 '17 at 22:55

1 Answers1

1

The Imports field in the DESCRIPTION file does not actually import anything. It only makes sure that the listed packages are installed when a user installs your package.

Instead, use NAMESPACE to make other packages or functions available to be used in your package. Also, don't edit NAMESPACE by hand, but use Roxygen2 (details here).

For this particular case, it means

#' @import DBI
setClass("KazamDriver", contains = "DBIDriver")
Heisenberg
  • 8,386
  • 12
  • 53
  • 102
  • I tried this and the error didn't go away. I later realized I had forgotten to include the package manually in the `Imports:` section of the `DESCRIPTION` file. This isn't done by roxygen2/devtools – akraf Oct 01 '18 at 12:27