Skip to content
Snippets Groups Projects
Commit 5accf2d2 authored by Ryan Senior's avatar Ryan Senior
Browse files

Minor changes for code cleanup

parent 7490bbdf
No related branches found
No related tags found
No related merge requests found
(ns metabase.driver.presto
(:require [clj-http.client :as http]
[clj-time
[core :as time]
[format :as tformat]]
[clojure
[set :as set]
[string :as str]]
......@@ -12,15 +15,10 @@
[util :as u]]
[metabase.driver.generic-sql :as sql]
[metabase.driver.generic-sql.util.unprepare :as unprepare]
[metabase.models
[field :as field]
[table :as table]]
[metabase.query-processor.util :as qputil]
[metabase.util
[honeysql-extensions :as hx]
[ssh :as ssh]]
[clj-time.format :as tformat]
[clj-time.core :as time])
[ssh :as ssh]])
(:import java.util.Date
[metabase.query_processor.interface DateTimeValue Value]))
......@@ -42,13 +40,11 @@
(defn- parse-time-with-tz [s]
;; Try parsing with offset first then with full ZoneId
(println "getting ready to parse " s)
(or (u/ignore-exceptions (u/parse-date "HH:mm:ss.SSS ZZ" s))
(u/parse-date "HH:mm:ss.SSS ZZZ" s)))
(defn- parse-timestamp-with-tz [s]
;; Try parsing with offset first then with full ZoneId
(println "getting ready to parse " s)
(or (u/ignore-exceptions (u/parse-date "yyyy-MM-dd HH:mm:ss.SSS ZZ" s))
(u/parse-date "yyyy-MM-dd HH:mm:ss.SSS ZZZ" s)))
......
......@@ -7,7 +7,9 @@
[query-processor-test :refer [rows]]
[sync :as sync]
[util :as u]]
[metabase.driver.generic-sql :as sql]
[metabase.driver
[generic-sql :as sql]
postgres]
[metabase.models
[database :refer [Database]]
[field :refer [Field]]
......
......@@ -327,8 +327,6 @@
(supports-report-timezone? *engine*)
[[23 49] [24 47] [25 39] [26 58] [27 7]]
(contains? #{:mongo :redshift :bigquery :postgres :vertica :h2 :presto} *engine*)
[[23 46] [24 47] [25 40] [26 60] [27 7]]
......
(ns metabase.sync.sync-metadata.sync-timezone-test
(:require [expectations :refer :all]
[toucan.util.test :as tt]
[metabase.models
[database :refer [Database]]
[table :refer [Table]]]
[toucan.db :as db]
[metabase.sync.sync-metadata.sync-timezone :as sync-tz]
[metabase.test.data.datasets :as datasets]
[metabase.test.data :as data]
[clj-time.core :as time]
[metabase.util :as u]))
(:require [clj-time.core :as time]
[metabase.models.database :refer [Database]]
[metabase.sync.sync-metadata.sync-timezone :as sync-tz]
[metabase.test.data :as data]
[metabase.test.data.datasets :as datasets]
[metabase.util :as u]
[toucan.db :as db]))
(defn- db-timezone [db-or-id]
(db/select-one-field :timezone Database :id (u/get-id db-or-id)))
;; This tests populating the timezone field for a given database. The
;; sync happens automatically, so this test removes it first to ensure
;; that it gets set when missing
(datasets/expect-with-engines #{:h2 :postgres}
[true true true]
(data/dataset test-data
......@@ -22,6 +21,10 @@
_ (db/update! Database (:id db) :timezone nil)
tz-after-update (db-timezone db)]
(sync-tz/sync-timezone! db)
;; On startup is the timezone specified?
[(boolean (time/time-zone-for-id tz-on-load))
;; Check to make sure the test removed the timezone
(nil? tz-after-update)
;; Check that the value was set again after sync
(boolean (time/time-zone-for-id (db-timezone db)))])))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment