-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to query long strings in cell contents with SQL Server #156
Comments
Because of the sensitivity of the data I cannot post the real data to reproduce. I haven't tried reproducing the error with a brand new database but I assume that if you create a very long string (in my case it's a json string of a 50k values array) and try to fetch it, you'll see similar behavior. Three query also returns fine using my windows odbc driver, but not using the professional odbc driver found on shinyappsio. |
What is the type of the column you are trying to retrieve? e.g. is it |
Looking at the table definition, it's Here are two examples of strings (json arrays) that don't work properly. Beware, long strings. Example 1
The query for a column containing this value with the professional odbc sql server driver returns
Example 2(longer) https://pastebin.com/4JL4DqFa Results in
|
Ok I can confirm this. Interestingly this works fine with the freeTDS drivers, but not with the Simba drivers. Writing the data works fine, it is only reading that seems to have an issue. In both cases I am connecting to the same database, here is a reproducible example x <- data.frame(stringsAsFactors = FALSE, x = scan("https://pastebin.com/raw/4JL4DqFa", what = "character"))
# Simba drivers
library(DBI);con <- dbConnect(odbc::odbc(), "SimbaSQLServer", UID = 'testuser', PWD = 'test');
dbWriteTable(con, "foo", x, field.types = c(x = "nvarchar(MAX)"), overwrite = TRUE)
dbReadTable(con, "foo")
# FreeTDS drivers
library(DBI);con2 <- dbConnect(odbc::odbc(), "SQLServer", UID = 'testuser', PWD = 'test');
dbReadTable(con2, "foo") |
Are you not able to reproduce the problem with the first shorter test? Would be simpler to work with |
I can reproduce it if I force the column type to be |
Ok I have determined a cause, this was a bug in the upstream nanodbc library, I fixed it locally by d2444e1 and opened an issue at the upstream repository nanodbc/nanodbc#160 |
I am on macOS Catalina Version 10.15.1, running R version 3.6.1. Facing exactly the same issue as described here by @daattali. While reading columns of type |
Issue Description and Expected Result
Posting this issue on behalf of Dean. He is unable to query long strings in cell contents from SQL Server using the pro drivers. Dean verified that the query works in isql so, this issue must be R related. He also mentioned that the query works with the RSQLServer package.
Database
SQL Server using the RStudio Pro Driver from shinyapps.io
Reproducible Example
Not available at this time
Details
Dean is having problems querying cell contents in SQL Server with very long strings. In short, he is querying data that is 1000's of characters long:
[xxx,yyy,...,zzz]
but the query only returns the last 17 characters:
2540, 2621, 2417]
The query he is using looks like this:
sql <- "SELECT [ConfigurationKey],[ConfigurationValue] FROM [Datalithic].[dbo].[UserConfiguration] WHERE [UserId]=19 AND [ConfigurationKey] IN ('CheckedConfig','CurrentWellList')"
res <- dbGetQuery(con, sql)
The text was updated successfully, but these errors were encountered: