RSQLite
RSQLite copied to clipboard
When empty `data.frame`s are returned, the column classes are not correct
When an empty data.frame is returned from a query, I am getting strange column classes for a SQLite connection. This does not happen in our PostgreSQL database.
conn <- DBI::dbConnect(RSQLite::SQLite(), dbFile, ...)
str(DBI::dbGetQuery(conn, "select * from tbl where foo = -1"))
# 'data.frame': 0 obs. of 4 variables:
# $ foo : num
# $ bar: chr
# $ zzz: chr
# $ tmp: logi
str(DBI::dbGetQuery(conn, "select * from tbl where foo = 1"))
# 'data.frame': 1 obs. of 4 variables:
# $ foo : int 1
# $ bar: chr "1"
# $ zzz: chr "hello"
# $ tmp: chr "world"