[R] The RSQLite version of dbGetQuery drops colums

Magnus Torfason zulutime.net at gmail.com
Fri Dec 18 18:11:53 CET 2009


Hi all,

I just noticed (the hard way of course) that when a query returns 0 
rows, the columns in the resulting data.frame get dropped as well. See 
the following example code (where conn is an active connection to an 
SQLite db):

 > dbGetQuery(conn, "select 1 as hey, 2 as ho where 1")
   hey ho
1   1  2
 > dbGetQuery(conn, "select 1 as hey, 2 as ho where 0")
data frame with 0 columns and 0 rows

I believe that the second query should return a 0x2 data.frame instead, 
that is, the same value as:

 > dbGetQuery(conn, "select 1 as hey, 2 as ho where 1")[FALSE,]
[1] hey ho
<0 rows> (or 0-length row.names)

Any thoughts? Is this a bug, and are the developers of RSQLite reading this?

Best regards,
Magnus




More information about the R-help mailing list