Skip to content
Snippets Groups Projects
Unverified Commit e0cded18 authored by Sameer Al-Sakran's avatar Sameer Al-Sakran Committed by GitHub
Browse files

Merge pull request #7548 from metabase/xray-fallback-to-generictable

xray: add fallback to GenericTable
parents 7412d488 cda99bf2
No related merge requests found
......@@ -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]
......@@ -768,9 +768,7 @@
(let [rules (rules/load-rules "table")]
(->> (apply db/select Table
(cond-> [:db_id (u/get-id database)
:visibility_type nil
:entity_type [:not= nil]] ; only consider tables that have alredy
; been analyzed
:visibility_type nil]
schema (concat [:schema schema])))
(filter mi/can-read?)
(map enhanced-table-stats)
......
......@@ -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
......@@ -195,34 +206,20 @@
(expect
[true true]
(tt/with-temp* [Table [{table-id :id}]]
(with-rasta
(with-dashboard-cleanup
(let [table (Table table-id)
not-analyzed-result (automagic-analysis table {})
analyzed-result (-> table
(assoc :entity_type :entity/GenericTable)
(automagic-analysis {}))]
[(nil? not-analyzed-result) (some? analyzed-result)])))))
3
(with-rasta
(->> (Database (data/id)) candidate-tables first :tables count)))
;; /candidates should work with unanalyzed tables
(expect
1
(tt/with-temp* [Database [{db-id :id}]
Table [{table-id :id} {:db_id db-id}]
Field [{} {:table_id table-id}]
Field [{} {:table_id table-id}]]
(with-rasta
(with-dashboard-cleanup
(let [database (Database db-id)
not-analyzed-count (count (candidate-tables database))]
(db/update! Table table-id :entity_type :entity/GenericTable)
(= (inc not-analyzed-count) (count (candidate-tables database))))))))
(expect
3
(with-rasta
(->> (Database (data/id)) candidate-tables first :tables count)))
(count (candidate-tables (Database db-id)))))))
;; Identity
......
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