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

Add escapes for dates and datetimes for MS Access #609

Merged
merged 7 commits into from
Apr 1, 2021
Merged

Add escapes for dates and datetimes for MS Access #609

merged 7 commits into from
Apr 1, 2021

Conversation

erikvona
Copy link
Contributor

@erikvona erikvona commented Mar 8, 2021

Closes #608

@erikvona erikvona marked this pull request as draft March 8, 2021 10:32
@erikvona erikvona marked this pull request as ready for review March 8, 2021 10:56
Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

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

Can you please add a bullet to the top of NEWS.md? It should briefly describe the change and end with (@yourname, #issuenumber).

R/backend-access.R Outdated Show resolved Hide resolved
sql_escape_datetime.ACCESS <- function(con, x) {
# Access delimits datetimes using octothorpes, and uses YYYY-MM-DD HH:MM:SS
# Timezones are not supported in Access
y <- format(x, "#%F %T#")
Copy link
Member

Choose a reason for hiding this comment

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

What does not supporting time zones imply here? Should we always generate a time in the system time zone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means timezone information is ignored when you escape a value that includes timezone information, e.g. escape(as.POSIXct('2020-01-01 01:01:01', tz = "US/Alaska"), con = simulate_access()) will result in the same thing as escape(as.POSIXct('2020-01-01 01:01:01', tz = "Europe/Berlin"), con = simulate_access()).

Some RDBMSes have a concept of timezones (e.g. SQL Server, Oracle) and when escaping a datetime field the timezone could be included, however, Access does not.

I assume that's a non-issue, especially since escapes for those databases (e.g. escape(as.POSIXct('2020-01-01 01:01:01', tz = 'US/Alaska'), con = simulate_mssql())) always provides the zulu timezone and also ignore timezone information. But that's a separate issue, and one that's considerably harder to address and might break existing code when addressed.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it. Thanks for the explanation!

@hadley hadley changed the title Add escapes for dates and datetimes Add escapes for dates and datetimes for MS Access Apr 1, 2021
erikvona and others added 4 commits April 1, 2021 21:11
@hadley hadley merged commit c8950cb into tidyverse:master Apr 1, 2021
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.

Dates in MS Access aren't escaped properly.
2 participants