r-dbi/DBI

Is it intended that DBI::Id() does not have a `as.character()` method?

jimhester opened this issue · 3 comments

Using DBI::Id() objects in places that convert objects to characters results in an error.

as.character(DBI::Id(blah = "foo"))
#> Error in as.character.default(DBI::Id(blah = "foo")): no method for coercing this S4 class to a vector
paste(DBI::Id(blah = "foo"))
#> Error in as.character.default(new("Id", name = c(blah = "foo"))): no method for coercing this S4 class to a vector

Created on 2020-01-10 by the reprex package (v0.3.0)

I see there is a toString() method defined for these objects, is the intention that all coercion to strings must be explicit and use toString()?

Ref: r-dbi/odbc#339

I guess so. I'd expect users to call dbQuoteIdentifier(con, id) to retrieve a printable representation. I was not aware of toString().

toString.Id() was effectively introduced in 18c8e85 and last touched in 31bd35f. I now consider breaking paste() a feature.

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.