diff --git a/src/metabase/automagic_dashboards/core.clj b/src/metabase/automagic_dashboards/core.clj index b479ead6b762baede773c8d2c4d80984fdebcc3d..87c8c89baf25fc675f1f933b0524669867f120c3 100644 --- a/src/metabase/automagic_dashboards/core.clj +++ b/src/metabase/automagic_dashboards/core.clj @@ -428,7 +428,7 @@ Most specific is defined as entity type specification the longest ancestor chain." [rules {:keys [source entity]}] - (let [table-type (:entity_type source)] + (let [table-type (or (:entity_type source) :entity/GenericTable)] (->> rules (filter (fn [{:keys [applies_to]}] (let [[entity-type field-type] applies_to] diff --git a/test/metabase/automagic_dashboards/core_test.clj b/test/metabase/automagic_dashboards/core_test.clj index 8e79c3634f5861a50725a5d4ef97da3edd7c3f72..bc4db454390bdcf4501760d9e0738f91c15a6c49 100644 --- a/test/metabase/automagic_dashboards/core_test.clj +++ b/test/metabase/automagic_dashboards/core_test.clj @@ -53,6 +53,17 @@ (#'magic/matching-rules (rules/load-rules "table")) (map (comp first :applies_to)))) +;; Test fallback to GenericTable +(expect + [:entity/GenericTable :entity/*] + (->> (-> (data/id :users) + Table + (assoc :entity_type nil) + (#'magic/->root)) + (#'magic/matching-rules (rules/load-rules "table")) + (map (comp first :applies_to)))) + + (defn- collect-urls [dashboard] (->> dashboard