1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
NULL
# Coercion rules ---------------------------------------------------------------
coerce <- function(sqlvar, from, to) {
list(from = from, to = to)
}
sqlDate <- function() {
coerce(
function(x) as.integer(x),
function(x) {
stopifnot(is.integer(x))
structure(x, class = "Date")
}
)
}
sqlDateTime <- function() {
coerce(
function(x) as.numeric(x),
function(x) {
stopifnot(is.numeric(x))
structure(x, class = c("POSIXct", "POSIXt"), tzone = "UTC")
}
)
}
sqlSerialize <- function() {
coerce(
function(x) {
lapply(x, serialize, connection = NULL)
},
function(x) {
lapply(x, unserialize)
}
)
}
sqlBoolean <- function() {
coerce(
function(x) as.integer(x),
function(x) as.logical(x)
)
}
sqlFactor <- function(levels) {
coerce(
function(x) as.integer(x),
function(x) factor(x, levels = levels)
)
}
|