Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

fixes https://github.com/hannesmuehleisen/MonetDBLite/issues/19 #154

Closed
wants to merge 3 commits into from

Conversation

ajdamico
Copy link
Contributor

No description provided.

@ajdamico
Copy link
Contributor Author

@hannesmuehleisen i doubt you like the SELECT * here but i'm not finding the alternative. using something like

dbGetQuery(db, paste0("select columns.name , columns.type from sys.columns join sys.tables on \
	columns.table_id=tables.id where tables.name='", qname , "'"))	

returns monetdb sql types rather than the five possible dbDataType results:

"BOOLEAN","INTEGER","DOUBLE PRECISION","BLOB","STRING"

this pull request checks three things during an append..

1. number of columns matches, then
2. names of columns match, then
3. dbDataType of columns match OR data.frame has INTEGER appending into a DOUBLE PRECISION column already in the database

..and then fixes this coercion issue:

> library(DBI)
> db <- dbConnect(MonetDBLite::MonetDBLite())
> dbWriteTable(db,'mtcars',mtcars)
> x<-mtcars
> x$mpg<-as.integer(x$mpg)
> dbWriteTable(db,'mtcars',x,append=T)
Error in .local(conn, name, value, ...) : 
  Failed to insert data: MALException:embedded:Could not convert column 0 mpg to type 10 

thanks

@ajdamico ajdamico requested a review from hannes June 11, 2017 00:17
@ajdamico
Copy link
Contributor Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants