Skip to content
Snippets Groups Projects
Unverified Commit c3a5d3b0 authored by Braden Shepherdson's avatar Braden Shepherdson Committed by GitHub
Browse files

Serdes v2: Fixing some more cases of malformed SQL with empty databases (#26134)

Mostly this was caused by `:id [:in []]` empty lists if eg. you don't
have any non-personal collections, or no dashboards exist.

Also I broke the argument passing to the selective dump command
`extract-subtrees` a while back and this fixes it.
parent 5ee26b4d
No related branches found
No related tags found
No related merge requests found
......@@ -166,14 +166,18 @@
serialized output."
[{:keys [selected-collections targets] :as opts}]
(log/tracef "Extracting subtrees with options: %s" (pr-str opts))
(if-let [analysis (escape-analysis selected-collections)]
;; If that is non-nil, emit the report.
(escape-report analysis)
;; If it's nil, there are no errors, and we can proceed to do the dump.
(let [closure (descendants-closure opts targets)
by-model (->> closure
(group-by first)
(m/map-vals #(set (map second %))))]
(eduction cat (for [[model ids] by-model]
(eduction (map #(serdes.base/extract-one model opts %))
(db/select-reducible (symbol model) :id [:in ids])))))))
(let [selected-collections (or selected-collections (->> targets
(filter #(= (first %) "Collection"))
(map second)
set))]
(if-let [analysis (escape-analysis selected-collections)]
;; If that is non-nil, emit the report.
(escape-report analysis)
;; If it's nil, there are no errors, and we can proceed to do the dump.
(let [closure (descendants-closure opts targets)
by-model (->> closure
(group-by first)
(m/map-vals #(set (map second %))))]
(eduction cat (for [[model ids] by-model]
(eduction (map #(serdes.base/extract-one model opts %))
(db/select-reducible (symbol model) :id [:in ids]))))))))
......@@ -224,7 +224,8 @@
(defmethod serdes.base/extract-query "DashboardCard" [_ {:keys [collection-set]}]
(if (seq collection-set)
(let [dashboards (db/select-ids 'Dashboard :collection_id [:in collection-set])]
(db/select-reducible DashboardCard :dashboard_id [:in dashboards]))
(when (seq dashboards)
(db/select-reducible DashboardCard :dashboard_id [:in dashboards])))
(db/select-reducible DashboardCard)))
(defmethod serdes.base/serdes-dependencies "DashboardCard"
......
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