odbc icon indicating copy to clipboard operation
odbc copied to clipboard

Export connection classes (or the `class_cache` env)

Open nbenn opened this issue 2 years ago • 1 comments

Issue Description and Expected Result

In a package, I'm trying to use S4 dispatch on one of the concrete connection classes ("Microsoft SQL Server"). For this I need to provide a class "definition". Simply calling setOldClass() does not do the trick as this is an actual S4 class provided by {odbc}. The only thing I got to work was doing

#' @importClassesFrom odbc OdbcConnection
setClass("Microsoft SQL Server", contains = "OdbcConnection",
         where = odbc:::class_cache)

Is exporting the corresponding classes in the cards? Or maybe the class_cache env?

Database

Any.

Reproducible Example

Happy to create one if helpful for making the issue clearer.

nbenn avatar Aug 17 '22 20:08 nbenn

I am also having this problem.

raubreywhite avatar Oct 05 '22 09:10 raubreywhite

@detule Do you have any information on this?

raubreywhite avatar Feb 28 '23 05:02 raubreywhite

I don't see a problem with exporting the class cache environment. @hadley any reasons to keep it internal?

detule avatar Feb 28 '23 15:02 detule

My baseline is to be very sceptical that exporting this internal implementation detail is a good idea in the long run.

hadley avatar Feb 28 '23 16:02 hadley

I know that it's frustrating that we don't provide better support for this, but creating S4 classes dynamically is fundamentally fragile and I don't think it's good to build further upon it. I think the only real fix is to eventually switch from S4 to S7, but that is still some time away.

hadley avatar Apr 24 '23 14:04 hadley