-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Originally posted here: ropensci/drake#1201
Overview
Within my drake workflow, when trying to store a particular dataframe, I keep getting the same error:
Error: NOT NULL constraint failed: datatable.value
This always occurs at the stage of attempting to store my dataframe
With some digging, I am able to find the name "datatable" wrt my cache:
cache$driver$tbl_data
#> [1] "datatable"After reviewing source for driver_dbi, I notice where this NOT NULL constraint is set.
I also notice the definitions for set_object.
I wonder if anyone has any idea how this datatable.value might be taken as NULL?
Lines
NOT NULL constraint set here:
Lines 171 to 173 in 0c64f1e
| sql <- c(sprintf("CREATE TABLE %s", dquote(tbl_data)), | |
| "(hash TEXT PRIMARY KEY NOT NULL,", | |
| sprintf("value %s NOT NULL)", data_type)) |
Defining set_object SQL Call:
Lines 514 to 515 in 0c64f1e
| set_object = j("INSERT OR REPLACE INTO", tbl_data, | |
| "(hash, value) VALUES (?, ?)"), |
Defining set_object method for driver_dbi:
Lines 305 to 312 in 0c64f1e
| set_object = function(hash, value) { | |
| ## TODO: Could tidy up the serialization inteface (I'm sure I | |
| ## have helpers for that somewhere). Though OTOH if we accept | |
| ## binary we can skip the serialisation here anyway with | |
| ## appropriate setting of traits. | |
| dat <- list(hash, if (self$binary) list(value) else value) | |
| DBI::dbExecute(self$con, self$sql$set_object, dat) | |
| }, |