The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Revisions: Show deleted collections as `#123` rather than null (#74026)
Braden Shepherdsonabfbd2815659
diff --git a/src/metabase/revisions/models/revision/diff.clj b/src/metabase/revisions/models/revision/diff.cljindex fdf4428688a..b666c87506e 100644--- a/src/metabase/revisions/models/revision/diff.clj+++ b/src/metabase/revisions/models/revision/diff.clj@@ -58,15 +58,18 @@[:collection_id nil coll-id](deferred-tru "moved {0} to {1}" identifier (if coll-id- (t2/select-one-fn :name 'Collection coll-id)+ (or (t2/select-one-fn :name 'Collection coll-id)+ (str "#" coll-id))(deferred-tru "Our analytics")))[:collection_id (prev-coll-id :guard int?) coll-id](deferred-tru "moved {0} from {1} to {2}"identifier- (t2/select-one-fn :name 'Collection prev-coll-id)+ (or (t2/select-one-fn :name 'Collection prev-coll-id)+ (str "#" prev-coll-id))(if coll-id- (t2/select-one-fn :name 'Collection coll-id)+ (or (t2/select-one-fn :name 'Collection coll-id)+ (str "#" coll-id))(deferred-tru "Our analytics")))[:visualization_settings _ _]diff --git a/test/metabase/revisions/impl/card_test.clj b/test/metabase/revisions/impl/card_test.cljindex 7cf0df5485c..09b31140d63 100644--- a/test/metabase/revisions/impl/card_test.clj+++ b/test/metabase/revisions/impl/card_test.clj@@ -37,6 +37,25 @@:description "New description"}"added a description and renamed it from \"Diff Test\" to \"Diff Test changed\"."))+;; Regression test for https://github.com/metabase/metabase/issues/73681+(deftest diff-cards-str-deleted-collection-test+ (mt/initialize-if-needed! :db)+ (testing "When a collection referenced in a revision has been deleted, the description should not show 'null'"+ (let [deleted-coll-id 99999]+ (are [x y expected] (= expected+ (u/build-sentence (revision/diff-strings :model/Card x y)))+ ;; moved from nil (root) to a now-deleted collection+ {:name "Apple"}+ {:name "Apple"+ :collection_id deleted-coll-id}+ (str "moved this Card to #" deleted-coll-id ".")++ ;; moved from a now-deleted collection back to root: should show ID, not "null"+ {:name "Apple"+ :collection_id deleted-coll-id}+ {:name "Apple"}+ (str "moved this Card from #" deleted-coll-id " to Our analytics.")))))+(deftest ^:parallel diff-cards-str-update-collection--test(mt/with-temp[:model/Collection {coll-id-1 :id} {:name "Old collection"}