Win, Rstudio 1.4, Rmarkdown SQL chunk. Special chars fails (encoding). Works in 1.3


I have a long working code including a SQL chunk fetching data from a database with variable names that includes special characters (æøå).

select distinct

In Rstudio 1.3 it works without problems
In Rstudio 1.4 it fails and the log shows it likely is because of encoding problems when the SQL is send to the server

From log:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '¸'

So "ø" is rendered and send to SQL server as "ø"
with same setting Rstudio 1.3 was rendering/sending as "ø"

It works fine (as normal) when query dosn't contains special characters.

I have not been able to find a solution - hope there is a work around ?

Best regards,

A possible work around is to avoid Rmarkdown inline SQL chunk that contains special characters in variable names

Work around:

sql_result <- dbGetQuery(conn, "
select distinct
from ...

I prefere the previous Rstudio 1.3 behavior where inline rmarkdown SQL chunk also worked with variable names containing spec. characters.

Brgds. Henrik

A small reprex. The problem exist in Rstudio 1.4 but not in 1.3

mydb <- dbConnect(RSQLite::SQLite(), "")

testdb <- tribble(~variable_name_normal, ~variable_name_spec_ø,
                  'value', 'value',
                  'æøå', 'æøå')

dbWriteTable(mydb, 'test_table', testdb, overwrite = TRUE)
```{sql, connection='mydb', output.var='local_file'}
from test_table

On Windows 7 prof and Windows 10 (both with Danish std. codepage) I get this error msg:

Fejl: no such column: variable_name_spec_ø
Failed to execute SQL chunk 

"ø" is rendered as "ø"
On my Mac - it works flawless, as it used to do on Windows in version 1.3

Hope this will do as a valid reprex :slight_smile:

Brgds. Henrik

Would you be willing to report this on our issue tracker?

Hi' Jonathan

Yes :slight_smile:

I'm not sure where to find the issue tracker ?
Edited: you allready provided the link. Sorry :slight_smile:

Brgds. Henrik

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.