Skip to content
Snippets Groups Projects
Commit c1cc38ac authored by Cam Saül's avatar Cam Saül
Browse files

Merge pull request #438 from metabase/allow_unsetting_field_special_type

allow `Field.special_type` to be unset via API :unamused:
parents 62206c17 979e431e
Branches
Tags
No related merge requests found
(ns metabase.api.meta.field
(:require [compojure.core :refer [GET PUT POST]]
[medley.core :as medley]
[medley.core :as m]
[metabase.api.common :refer :all]
[metabase.db :refer :all]
[metabase.db.metadata-queries :as metadata]
......@@ -36,14 +36,13 @@
(defendpoint PUT "/:id"
"Update `Field` with ID."
[id :as {{:keys [field_type special_type preview_display description]} :body}]
{field_type FieldType
{field_type FieldType
special_type FieldSpecialType}
(write-check Field id)
(check-500 (upd-non-nil-keys Field id
:field_type field_type
:special_type special_type
:preview_display preview_display
:description description))
(check-500 (m/mapply upd Field id (merge {:description description ; you're allowed to unset description and special_type
:special_type special_type} ; but field_type and preview_display must be replaced
(when field_type {:field_type field_type}) ; with new non-nil values
(when preview_display {:preview_display preview_display}))))
(sel :one Field :id id))
(defendpoint GET "/:id/summary"
......
......@@ -67,16 +67,16 @@
:restarted]
[(do
(stop-task-runner!)
(with-redefs [metabase.task/hourly-task-delay (constantly 50)
(with-redefs [metabase.task/hourly-task-delay (constantly 100)
metabase.task/hourly-tasks-hook mock-hourly-tasks-hook]
(add-hook! #'hourly-tasks-hook inc-task-test-atom-counter-by-system-hour)
(reset! task-test-atom-counter 0)
(start-task-runner!)
[@task-test-atom-counter ; should be 0, since not enough time has elaspsed for the hook to be executed
(do (Thread/sleep 75)
@task-test-atom-counter) ; should have been called once (~25ms ago)
(do (Thread/sleep 100)
(do (Thread/sleep 150)
@task-test-atom-counter) ; should have been called once (~50ms ago)
(do (Thread/sleep 200)
@task-test-atom-counter) ; should have been called two more times
(do (stop-task-runner!)
:stopped)]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment