{"action":"created","comment":{"url":"https://api.github.com/repos/metabase/metabase/pulls/comments/54666287","id":54666287,"diff_hunk":"@@ -27,9 +27,8 @@\n              (.setAutoCommit jdbc-connection false)\n              (try\n                ;; Set the timezone if applicable\n-               (when-let [timezone (driver/report-timezone)]\n-                 (when (and (seq timezone)\n-                            (contains? (driver/features driver) :set-timezone))\n+               (when-let [timezone (:report-timezone settings)]\n+                 (when (seq timezone)","path":"src/metabase/driver/generic_sql/native.clj","position":17,"original_position":17,"commit_id":"3aebb0376a16fa32c024cb843e20c70943260b38","original_commit_id":"3aebb0376a16fa32c024cb843e20c70943260b38","user":{"login":"agilliland","id":1987787,"avatar_url":"https://avatars.githubusercontent.com/u/1987787?v=3","gravatar_id":"","url":"https://api.github.com/users/agilliland","html_url":"https://github.com/agilliland","followers_url":"https://api.github.com/users/agilliland/followers","following_url":"https://api.github.com/users/agilliland/following{/other_user}","gists_url":"https://api.github.com/users/agilliland/gists{/gist_id}","starred_url":"https://api.github.com/users/agilliland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agilliland/subscriptions","organizations_url":"https://api.github.com/users/agilliland/orgs","repos_url":"https://api.github.com/users/agilliland/repos","events_url":"https://api.github.com/users/agilliland/events{/privacy}","received_events_url":"https://api.github.com/users/agilliland/received_events","type":"User","site_admin":false},"body":"that check still takes place, but it happens when the `:settings` are added to the query in our QP middleware ... https://github.com/metabase/metabase/blob/3aebb0376a16fa32c024cb843e20c70943260b38/src/metabase/driver/query_processor.clj#L116-L119\r\n\r\nSo the benefit is that redundant checking code like this can be eliminated from each individual driver because the drivers can now simply use the value presented on the query :settings and trust that it's been validated already.  In this case the `(when-let [timezone (:report-timezone settings)]` binding does everything we need because if the timezone exists in the query settings then we should use it, otherwise move on.","created_at":"2016-03-02T01:26:58Z","updated_at":"2016-03-02T01:26:58Z","html_url":"https://github.com/metabase/metabase/pull/2062#discussion_r54666287","pull_request_url":"https://api.github.com/repos/metabase/metabase/pulls/2062","_links":{"self":{"href":"https://api.github.com/repos/metabase/metabase/pulls/comments/54666287"},"html":{"href":"https://github.com/metabase/metabase/pull/2062#discussion_r54666287"},"pull_request":{"href":"https://api.github.com/repos/metabase/metabase/pulls/2062"}}},"pull_request":{"url":"https://api.github.com/repos/metabase/metabase/pulls/2062","id":61198357,"html_url":"https://github.com/metabase/metabase/pull/2062","diff_url":"https://github.com/metabase/metabase/pull/2062.diff","patch_url":"https://github.com/metabase/metabase/pull/2062.patch","issue_url":"https://api.github.com/repos/metabase/metabase/issues/2062","number":2062,"state":"open","locked":false,"title":"Format QP temporal values using the reporting timezone","user":{"login":"agilliland","id":1987787,"avatar_url":"https://avatars.githubusercontent.com/u/1987787?v=3","gravatar_id":"","url":"https://api.github.com/users/agilliland","html_url":"https://github.com/agilliland","followers_url":"https://api.github.com/users/agilliland/followers","following_url":"https://api.github.com/users/agilliland/following{/other_user}","gists_url":"https://api.github.com/users/agilliland/gists{/gist_id}","starred_url":"https://api.github.com/users/agilliland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agilliland/subscriptions","organizations_url":"https://api.github.com/users/agilliland/orgs","repos_url":"https://api.github.com/users/agilliland/repos","events_url":"https://api.github.com/users/agilliland/events{/privacy}","received_events_url":"https://api.github.com/users/agilliland/received_events","type":"User","site_admin":false},"body":"Resolves #2034 \r\n\r\nPreviously all query result values of a temporal type (java.sql.Date, java.sql.Timestamp, or java.util.Date) were being left unformatted until they hit the JSON serializer in our api middleware (https://github.com/metabase/metabase/blob/format-qp-results-in-timezone/src/metabase/middleware.clj#L205-L207) which was then formatting them as ISO8601 timestamps in UTC by default.\r\n\r\nThat's a good default for our api, but for query results we really want to be formatting the values in the reporting timezone, so this PR adds a little formatting code to the QP middleware which proactively formats temporal values as ISO8601 values _WITH_ the reporting timezone offset.\r\n\r\nIn addition to formatting the query result values with the report timezone this PR also introduces another small piece of QP middleware in pre-processing which looks up the `:report-timezone` setting from the MB instance and adds it to a :settings dictionary on the query.  This just makes it easier for the QP code and drivers to access and use the report timezone value because instead of having various places in the code looking up the value separately it's now accessed in one place and available to all QP code without any effort.","created_at":"2016-03-01T06:17:38Z","updated_at":"2016-03-02T01:26:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a27175a89dc19d30cf6f0e33ec8f89946ae5ab96","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/metabase/metabase/pulls/2062/commits","review_comments_url":"https://api.github.com/repos/metabase/metabase/pulls/2062/comments","review_comment_url":"https://api.github.com/repos/metabase/metabase/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metabase/metabase/issues/2062/comments","statuses_url":"https://api.github.com/repos/metabase/metabase/statuses/3aebb0376a16fa32c024cb843e20c70943260b38","head":{"label":"metabase:format-qp-results-in-timezone","ref":"format-qp-results-in-timezone","sha":"3aebb0376a16fa32c024cb843e20c70943260b38","user":{"login":"metabase","id":10520629,"avatar_url":"https://avatars.githubusercontent.com/u/10520629?v=3","gravatar_id":"","url":"https://api.github.com/users/metabase","html_url":"https://github.com/metabase","followers_url":"https://api.github.com/users/metabase/followers","following_url":"https://api.github.com/users/metabase/following{/other_user}","gists_url":"https://api.github.com/users/metabase/gists{/gist_id}","starred_url":"https://api.github.com/users/metabase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metabase/subscriptions","organizations_url":"https://api.github.com/users/metabase/orgs","repos_url":"https://api.github.com/users/metabase/repos","events_url":"https://api.github.com/users/metabase/events{/privacy}","received_events_url":"https://api.github.com/users/metabase/received_events","type":"Organization","site_admin":false},"repo":{"id":30203935,"name":"metabase","full_name":"metabase/metabase","owner":{"login":"metabase","id":10520629,"avatar_url":"https://avatars.githubusercontent.com/u/10520629?v=3","gravatar_id":"","url":"https://api.github.com/users/metabase","html_url":"https://github.com/metabase","followers_url":"https://api.github.com/users/metabase/followers","following_url":"https://api.github.com/users/metabase/following{/other_user}","gists_url":"https://api.github.com/users/metabase/gists{/gist_id}","starred_url":"https://api.github.com/users/metabase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metabase/subscriptions","organizations_url":"https://api.github.com/users/metabase/orgs","repos_url":"https://api.github.com/users/metabase/repos","events_url":"https://api.github.com/users/metabase/events{/privacy}","received_events_url":"https://api.github.com/users/metabase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metabase/metabase","description":"The simplest, fastest way to get business intelligence and analytics  to everyone in your company :yum:","fork":false,"url":"https://api.github.com/repos/metabase/metabase","forks_url":"https://api.github.com/repos/metabase/metabase/forks","keys_url":"https://api.github.com/repos/metabase/metabase/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metabase/metabase/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metabase/metabase/teams","hooks_url":"https://api.github.com/repos/metabase/metabase/hooks","issue_events_url":"https://api.github.com/repos/metabase/metabase/issues/events{/number}","events_url":"https://api.github.com/repos/metabase/metabase/events","assignees_url":"https://api.github.com/repos/metabase/metabase/assignees{/user}","branches_url":"https://api.github.com/repos/metabase/metabase/branches{/branch}","tags_url":"https://api.github.com/repos/metabase/metabase/tags","blobs_url":"https://api.github.com/repos/metabase/metabase/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metabase/metabase/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metabase/metabase/git/refs{/sha}","trees_url":"https://api.github.com/repos/metabase/metabase/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metabase/metabase/statuses/{sha}","languages_url":"https://api.github.com/repos/metabase/metabase/languages","stargazers_url":"https://api.github.com/repos/metabase/metabase/stargazers","contributors_url":"https://api.github.com/repos/metabase/metabase/contributors","subscribers_url":"https://api.github.com/repos/metabase/metabase/subscribers","subscription_url":"https://api.github.com/repos/metabase/metabase/subscription","commits_url":"https://api.github.com/repos/metabase/metabase/commits{/sha}","git_commits_url":"https://api.github.com/repos/metabase/metabase/git/commits{/sha}","comments_url":"https://api.github.com/repos/metabase/metabase/comments{/number}","issue_comment_url":"https://api.github.com/repos/metabase/metabase/issues/comments{/number}","contents_url":"https://api.github.com/repos/metabase/metabase/contents/{+path}","compare_url":"https://api.github.com/repos/metabase/metabase/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metabase/metabase/merges","archive_url":"https://api.github.com/repos/metabase/metabase/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metabase/metabase/downloads","issues_url":"https://api.github.com/repos/metabase/metabase/issues{/number}","pulls_url":"https://api.github.com/repos/metabase/metabase/pulls{/number}","milestones_url":"https://api.github.com/repos/metabase/metabase/milestones{/number}","notifications_url":"https://api.github.com/repos/metabase/metabase/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metabase/metabase/labels{/name}","releases_url":"https://api.github.com/repos/metabase/metabase/releases{/id}","deployments_url":"https://api.github.com/repos/metabase/metabase/deployments","created_at":"2015-02-02T19:25:47Z","updated_at":"2016-03-01T18:38:10Z","pushed_at":"2016-03-02T01:13:23Z","git_url":"git://github.com/metabase/metabase.git","ssh_url":"git@github.com:metabase/metabase.git","clone_url":"https://github.com/metabase/metabase.git","svn_url":"https://github.com/metabase/metabase","homepage":"http://metabase.com","size":32777,"stargazers_count":2307,"watchers_count":2307,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":113,"mirror_url":null,"open_issues_count":250,"forks":113,"open_issues":250,"watchers":2307,"default_branch":"master"}},"base":{"label":"metabase:master","ref":"master","sha":"e5a4da616ab08b0e464e6e2580a6f103b37080ca","user":{"login":"metabase","id":10520629,"avatar_url":"https://avatars.githubusercontent.com/u/10520629?v=3","gravatar_id":"","url":"https://api.github.com/users/metabase","html_url":"https://github.com/metabase","followers_url":"https://api.github.com/users/metabase/followers","following_url":"https://api.github.com/users/metabase/following{/other_user}","gists_url":"https://api.github.com/users/metabase/gists{/gist_id}","starred_url":"https://api.github.com/users/metabase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metabase/subscriptions","organizations_url":"https://api.github.com/users/metabase/orgs","repos_url":"https://api.github.com/users/metabase/repos","events_url":"https://api.github.com/users/metabase/events{/privacy}","received_events_url":"https://api.github.com/users/metabase/received_events","type":"Organization","site_admin":false},"repo":{"id":30203935,"name":"metabase","full_name":"metabase/metabase","owner":{"login":"metabase","id":10520629,"avatar_url":"https://avatars.githubusercontent.com/u/10520629?v=3","gravatar_id":"","url":"https://api.github.com/users/metabase","html_url":"https://github.com/metabase","followers_url":"https://api.github.com/users/metabase/followers","following_url":"https://api.github.com/users/metabase/following{/other_user}","gists_url":"https://api.github.com/users/metabase/gists{/gist_id}","starred_url":"https://api.github.com/users/metabase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metabase/subscriptions","organizations_url":"https://api.github.com/users/metabase/orgs","repos_url":"https://api.github.com/users/metabase/repos","events_url":"https://api.github.com/users/metabase/events{/privacy}","received_events_url":"https://api.github.com/users/metabase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metabase/metabase","description":"The simplest, fastest way to get business intelligence and analytics  to everyone in your company :yum:","fork":false,"url":"https://api.github.com/repos/metabase/metabase","forks_url":"https://api.github.com/repos/metabase/metabase/forks","keys_url":"https://api.github.com/repos/metabase/metabase/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metabase/metabase/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metabase/metabase/teams","hooks_url":"https://api.github.com/repos/metabase/metabase/hooks","issue_events_url":"https://api.github.com/repos/metabase/metabase/issues/events{/number}","events_url":"https://api.github.com/repos/metabase/metabase/events","assignees_url":"https://api.github.com/repos/metabase/metabase/assignees{/user}","branches_url":"https://api.github.com/repos/metabase/metabase/branches{/branch}","tags_url":"https://api.github.com/repos/metabase/metabase/tags","blobs_url":"https://api.github.com/repos/metabase/metabase/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metabase/metabase/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metabase/metabase/git/refs{/sha}","trees_url":"https://api.github.com/repos/metabase/metabase/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metabase/metabase/statuses/{sha}","languages_url":"https://api.github.com/repos/metabase/metabase/languages","stargazers_url":"https://api.github.com/repos/metabase/metabase/stargazers","contributors_url":"https://api.github.com/repos/metabase/metabase/contributors","subscribers_url":"https://api.github.com/repos/metabase/metabase/subscribers","subscription_url":"https://api.github.com/repos/metabase/metabase/subscription","commits_url":"https://api.github.com/repos/metabase/metabase/commits{/sha}","git_commits_url":"https://api.github.com/repos/metabase/metabase/git/commits{/sha}","comments_url":"https://api.github.com/repos/metabase/metabase/comments{/number}","issue_comment_url":"https://api.github.com/repos/metabase/metabase/issues/comments{/number}","contents_url":"https://api.github.com/repos/metabase/metabase/contents/{+path}","compare_url":"https://api.github.com/repos/metabase/metabase/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metabase/metabase/merges","archive_url":"https://api.github.com/repos/metabase/metabase/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metabase/metabase/downloads","issues_url":"https://api.github.com/repos/metabase/metabase/issues{/number}","pulls_url":"https://api.github.com/repos/metabase/metabase/pulls{/number}","milestones_url":"https://api.github.com/repos/metabase/metabase/milestones{/number}","notifications_url":"https://api.github.com/repos/metabase/metabase/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metabase/metabase/labels{/name}","releases_url":"https://api.github.com/repos/metabase/metabase/releases{/id}","deployments_url":"https://api.github.com/repos/metabase/metabase/deployments","created_at":"2015-02-02T19:25:47Z","updated_at":"2016-03-01T18:38:10Z","pushed_at":"2016-03-02T01:13:23Z","git_url":"git://github.com/metabase/metabase.git","ssh_url":"git@github.com:metabase/metabase.git","clone_url":"https://github.com/metabase/metabase.git","svn_url":"https://github.com/metabase/metabase","homepage":"http://metabase.com","size":32777,"stargazers_count":2307,"watchers_count":2307,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":113,"mirror_url":null,"open_issues_count":250,"forks":113,"open_issues":250,"watchers":2307,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metabase/metabase/pulls/2062"},"html":{"href":"https://github.com/metabase/metabase/pull/2062"},"issue":{"href":"https://api.github.com/repos/metabase/metabase/issues/2062"},"comments":{"href":"https://api.github.com/repos/metabase/metabase/issues/2062/comments"},"review_comments":{"href":"https://api.github.com/repos/metabase/metabase/pulls/2062/comments"},"review_comment":{"href":"https://api.github.com/repos/metabase/metabase/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metabase/metabase/pulls/2062/commits"},"statuses":{"href":"https://api.github.com/repos/metabase/metabase/statuses/3aebb0376a16fa32c024cb843e20c70943260b38"}}}}