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
Make default-source-table-entry deterministic and field-safe (#77725)
Chris Truterfc7d1ec13b1e
diff --git a/test/metabase/transforms/test_util.clj b/test/metabase/transforms/test_util.cljindex 10b7bddd8ee..df5f8475c75 100644--- a/test/metabase/transforms/test_util.clj+++ b/test/metabase/transforms/test_util.clj@@ -30,11 +30,27 @@{:alias alias :table_id table-id :database_id db_id :schema schema}))(defn default-source-table-entry- "Build a source-table-entry for the first active table in the current test database."+ "Build a source-table-entry for an active, field-synced table in the current test database.+ Deterministic: orders by id and requires a synced field."([](default-source-table-entry "test"))([alias]- (source-table-entry alias (t2/select-one-pk :model/Table :db_id (mt/id) :active true))))+ ;; Requiring a field skips field-less leftovers (un-synced transform targets, or Snowflake tables whose+ ;; columns haven't propagated yet) that would make the QP throw "Table has no Fields associated with it".+ (source-table-entry alias+ (t2/select-one-pk :model/Table+ :db_id (mt/id)+ :active true+ :id [:in {:select [:table_id]+ :from [(t2/table-name :model/Field)]+ ;; Mirror the QP's queryable-column filter (active-column-pred):+ ;; active, and visibility not sensitive/retired, else the picked+ ;; table still yields no implicit fields.+ :where [:and+ [:= :active true]+ [:or [:= :visibility_type nil]+ [:not-in :visibility_type ["sensitive" "retired"]]]]}]+ {:order-by [[:id :asc]]}))))(defn drop-target!"Drop transform target `target` and clean up its metadata.