Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists of raw vectors should map to blobs by default #49

Closed
krlmlr opened this issue Nov 8, 2015 · 5 comments · Fixed by #97
Closed

Lists of raw vectors should map to blobs by default #49

krlmlr opened this issue Nov 8, 2015 · 5 comments · Fixed by #97
Milestone

Comments

@krlmlr
Copy link
Member

krlmlr commented Nov 8, 2015

RPostgres, RMySQL and RSQLite map those to BLOBs. However, DBI doesn't declare the dbDataType method for lists, and the BLOB data type doesn't seem to be part of SQL-92.

Shall we add

setMethod("dbiDataType", "list", function(x) "blob")

to DBI?

CC @hannesmuehleisen.

@hannes
Copy link
Contributor

hannes commented Nov 9, 2015

fine with me.

@hadley
Copy link
Member

hadley commented Nov 9, 2015

How would lists get serialised into the database? I think this is part of a broader issue of allowing people to register custom serialisers and deserialisers for non-standard SQL types/R classes.

@krlmlr
Copy link
Member Author

krlmlr commented Nov 9, 2015

Lists (with raw vectors inside) already seem to be serialized as BLOBs in the existing rstats-db backends, but I don't have a test for that yet.

@krlmlr krlmlr changed the title Think about data type mapping for lists Lists should map to blobs by default Nov 11, 2015
@hadley hadley changed the title Lists should map to blobs by default Lists of raw vectors should map to blobs by default Nov 11, 2015
@hadley
Copy link
Member

hadley commented Nov 11, 2015

On option would be to do something like this:

setMethod("dbiDataType", "list", function(x) {
  is_raw <- vapply(x, is.raw, logical(1))
  if (all(is_raw)) {
    return("blob")
  }

  stop("Only lists of raw vectors are currently support", call. = FALSE)
})

@krlmlr
Copy link
Member Author

krlmlr commented Nov 12, 2015

A thin S3 wrapper is another option:

as.raw_list <- function(x) {
  check_raw_list(x)
  structure(x, class = "raw_list")
}

Here, the checking needs to be done only once during construction.

@krlmlr krlmlr added this to the 0.3.2 milestone Mar 30, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants