RSQLite icon indicating copy to clipboard operation
RSQLite copied to clipboard

When empty `data.frame`s are returned, the column classes are not correct

Open nathaneastwood opened this issue 2 years ago • 4 comments

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"

nathaneastwood avatar Feb 10 '23 10:02 nathaneastwood