Skip to content
Snippets Groups Projects
Unverified Commit 879195de authored by Alexander Solovyov's avatar Alexander Solovyov Committed by GitHub
Browse files

[serdes] query action depends on stuff in its dataset_query (#47220)

parent 0dd4013d
Branches
Tags
No related merge requests found
......@@ -871,7 +871,7 @@
(let [ser (ts/extract-one "Action" action-id)]
(is (=? {:serdes/meta [{:model "Action" :id (:entity_id action) :label "my_action"}]
:creator_id "ann@heart.band"
:type :implicit
:type "implicit"
:created_at string?
:model_id card-eid-1
:implicit [{:kind "row/update"}]}
......@@ -909,7 +909,7 @@
(let [ser (ts/extract-one "Action" action-id)]
(is (=? {:serdes/meta [{:model "Action" :id (:entity_id action) :label "my_action"}]
:creator_id "ann@heart.band"
:type :http
:type "http"
:created_at string?
:model_id card-eid-1
:http [{:template {}}]}
......@@ -949,7 +949,7 @@
(is (=? {:serdes/meta [{:model "Action"
:id (:entity_id action)
:label "my_action"}]
:type :query
:type "query"
:creator_id "ann@heart.band"
:created_at string?
:query [{:dataset_query {:database "My Database"
......
......@@ -973,7 +973,7 @@
@serialized))]
(is (some? action-serialized))
(testing ":type should be a string"
(is (keyword? (:type action-serialized))))))))
(is (string? (:type action-serialized))))))))
(testing "loading succeeds"
(ts/with-db dest-db
(serdes.load/load-metabase! (ingestion-in-memory @serialized))
......
......@@ -365,9 +365,10 @@
:transform {:action_id (serdes/parent-ref)}})
(defmethod serdes/make-spec "Action" [_model-name opts]
{:copy [:archived :description :entity_id :name :public_uuid :type]
{:copy [:archived :description :entity_id :name :public_uuid]
:skip []
:transform {:created_at (serdes/date)
:type (serdes/kw)
:creator_id (serdes/fk :model/User)
:made_public_by_id (serdes/fk :model/User)
:model_id (serdes/fk :model/Card)
......@@ -385,7 +386,8 @@
(concat
;; other stuff is implicitly referenced through a Card
[[{:model "Card" :id (:model_id action)}]]
(when (= (:type action) :query)
;; this method is called on ingested data before transformation and so here it always will be a string
(when (= (:type action) "query")
(concat
[[{:model "Database" :id (-> action :query first :database_id)}]]
(serdes/mbql-deps (:dataset_query action)))))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment