ropensci / nodbi

Document DBI connector for R
https://docs.ropensci.org/nodbi
Other
76 stars 6 forks source link

Fix for handling multibyte characters in JSON strings when using src_sqlite() #33

Closed rfhb closed 4 years ago

rfhb commented 4 years ago

This PR fixes an perhaps rare error of functions docdb_{get,query}() when using an src_sqlite() connection with certain multibyte characters in the JSON data, under Windows. The error reads,

> nodbi::docdb_get(src, key)
Error in FUN(X[[i]], ...) : invalid multibyte string, element 1

To address the issue, the streaming of the JSON string using cat was changed to use a connection object, because the latter permits to specify an encoding (UTF-8, compare help(connections), section Encoding). Into this PR, the removal of the temporary file was added (which I previously overlooked).

sckott commented 4 years ago

thanks, having a look

sckott commented 4 years ago

LGTM