-
Notifications
You must be signed in to change notification settings - Fork 78
Description
I have a custom backend where we need a custom method for dbDataType() for logical() ("BOOL" instead of "SMALLINT").
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
I'd rather back up to the default dispatch where possible, so instead of writing out a full custom R type->backend type mapping, I've just added one method for logical():
setMethod(
"dbDataType", c("MyDBIConnection", "logical"),
\(dbObj, obj, ...) "BOOL"
)However, that fails the {DBItest} suite:
`expect_identical(...)` threw an unexpected error. ('test-DBITest.R:54:1')
--------------------------------------------------------------------------------
`expect_identical(...)` threw an unexpected error.
Message: dbDataType(dbObj, I(FALSE)) (`actual`) not identical to dbDataType(dbObj, FALSE) (`expected`).
`actual`: "SMALLINT"
`expected`: "BOOL"
Class: expectation_failure/expectation/error/condition
My S4 knowledge is pretty weak, but IIUC the issue is that AsIs does not dispatch to the correct method:
Lines 1 to 6 in 9d28b2a
| dbiDataType_AsIs <- function(x) { | |
| oldClass(x) <- oldClass(x)[-1] | |
| dbiDataType(x) | |
| } | |
| setMethod("dbiDataType", signature("AsIs"), dbiDataType_AsIs) |
So I had to wind up just copy-pasting that as a new c("MyDBIConnection", "AsIs") method.
But shouldn't that be the default behavior so I don't need to copy over boilerplate? That would just mean adding a specific c("DBIConnection", "AsIs") method, right?
(happy to file a PR, but checking my understanding first)