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

Need to explain difference in dates when inserting rows #214

Open
jimtyhurst opened this issue Feb 16, 2019 · 0 comments
Open

Need to explain difference in dates when inserting rows #214

jimtyhurst opened this issue Feb 16, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@jimtyhurst
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
In Ch. 13 "SQL joins and complex queries":

  • Data inserted with dbExecute and SQL code has date fields initialized with now() or now()::date, which is executed within the PostgreSQL server, which seems to use UTC time.
  • Data inserted with dbWriteTable and a data.frame initialized with R code Sys.date() or Sys.time() has the local time from my workstation.

This leads to confusion as one works through the chapter, because the row inserted first with dbExecute has a later timestamp than the record inserted second with dbWriteTable.

Describe the solution you'd like
Ch. 13 should be enhanced to explain this issue, which is a common problem for web application developers. In general, timestamps should be supplied by the server, not by clients. This can be done by configuring the database with triggers or default values for fields.

Describe alternatives you've considered
We could just ignore the issue and address it during the workshop if anybody notices. This is not a specific problem for using R and SQL. It just happens to be highlighted in this chapter with the two ways of inserting records.

@jimtyhurst jimtyhurst added the enhancement New feature or request label Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant