Skip to content
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

Feature/independent column name encoding #845

Merged
merged 9 commits into from
Oct 30, 2024

Conversation

detule
Copy link
Collaborator

@detule detule commented Sep 6, 2024

This closes #834.

Some history:

To handle this, in this PR:

  • I separated the contents and field name encoders into separate arguments to dbConnect. New argument is columnNameEncoding.
  • As a small optimization, I made the encoder resources part of the connection. Previously they were allocated for each result.

To do before merging:

  • Add news item.
  • Deal with testthat/windows/utf-8.

Copy link
Collaborator

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stellar.💫

R/dbi-driver.R Outdated Show resolved Hide resolved
tests/testthat/test-driver-sql-server.R Outdated Show resolved Hide resolved
tests/testthat/test-driver-sql-server.R Outdated Show resolved Hide resolved
tests/testthat/test-driver-sql-server.R Outdated Show resolved Hide resolved
src/odbc_connection.h Show resolved Hide resolved
R/dbi-driver.R Outdated Show resolved Hide resolved
@@ -48,6 +48,10 @@ setMethod("show", "OdbcDriver",
#' not using UTF-8 you will need to set the encoding to get accurate
#' re-encoding. See [iconvlist()] for a complete list of available encodings
#' on your system. Note strings are always returned `UTF-8` encoded.
#' @param columnNameEncoding The text encoding for column names used on the
#' Database. May be different than the `encoding` argument. Defaults to
#' empty string which is equivalent to returning the column names without
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly surprised that this doesn't default to encoding. Are the column names and values encoded differently that often?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Hadley:

The issue that precipitated this PR is an instance where the content is encoded latin1 but the names are UTF-8. Prior to 1.5.0 the names were never de/coded regardless how how the encoding argument was specified, so in a sense we are just reverting to prior behavior, while retaining the flexibility that @shrektan added in 1.5.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that makes sense.

R/dbi-driver.R Outdated Show resolved Hide resolved
@hadley
Copy link
Member

hadley commented Oct 29, 2024

I think this is good to merge?

@simonpcouch
Copy link
Collaborator

Thumbs up from me!

@detule detule merged commit ab9421f into r-dbi:main Oct 30, 2024
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encoding/Collation problems with 1.5.0 SQL server
3 participants