Type mapping functions are functions that perform conversions between types as they are received from JDBC to R objects. For any JDBC type it is possible to define a function which is called before returning results from fetch().

dbSetTypeMaps() function sets, removes or lists the mapping functions.

dbSetTypeMaps(...)

Arguments

...

one or more arguments of the form TYPE=function(x) ... (set a new conversion function) or TYPE=NULL (remove conversion). If empty, no changes are made.

Details

The type names correspond to the column type names as defined by JDBC (see java.sql.Types Java documentation). For example, if you want to convert NUMERIC columns to numeric values in R (regardless of precision)

Value

Named list of currently registered type mapping functions. If

... is empty then visibly, otherwise invisibly.

Examples

str(dbSetTypeMaps())
#> List of 3
#>  $ DATETIME :function (x)  
#>  $ TIMESTAMP:function (x)  
#>  $ DATE     :function (x)  

## use bit64::as.integer64 (if available) to convert BIGINT to integer64
if (is.environment(bit64 <- tryCatch(getNamespace("bit64"), error=function(e) FALSE)))
    dbSetTypeMaps(BIGINT=bit64$as.integer64)