Skip to content
Snippets Groups Projects
Unverified Commit b256862f authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Merge pull request #7392 from metabase/upwlabs-hide-deleted-columns

Upwlabs hide deleted columns
parents cd956bd8 0fb6eb3b
Branches
Tags
No related merge requests found
......@@ -62,7 +62,11 @@
(defn fields
"Return the `FIELDS` belonging to a single TABLE."
[{:keys [id]}]
(db/select Field, :table_id id :visibility_type [:not= "retired"], {:order-by [[:position :asc] [:name :asc]]}))
(db/select Field
:table_id id
:active true
:visibility_type [:not= "retired"]
{:order-by [[:position :asc] [:name :asc]]}))
(defn metrics
"Retrieve the `Metrics` for a single TABLE."
......@@ -127,6 +131,7 @@
(with-objects :fields
(fn [table-ids]
(db/select Field
:active true
:table_id [:in table-ids]
:visibility_type [:not= "retired"]
{:order-by [[:position :asc] [:name :asc]]}))
......
......@@ -14,11 +14,10 @@
[database :refer [Database]]
[field :refer [Field]]
[table :refer [Table]]]
[metabase.test.data
[generic-sql :as sql-test-data]
h2
[interface :as tdi]]
[toucan.db :as db]
[metabase.test.data.interface :as tdi]
[toucan
[db :as db]
[hydrate :refer [hydrate]]]
[toucan.util.test :as tt]))
(defn- with-test-db-before-and-after-dropping-a-column
......@@ -79,6 +78,15 @@
(db/select [Field :name :active]
:table_id [:in (db/select-ids Table :db_id (u/get-id database))]))))))
;; make sure deleted fields doesn't show up in `:fields` of a table
(expect
{:before-drop #{"species" "example_name"}
:after-drop #{"species"}}
(with-test-db-before-and-after-dropping-a-column
(fn [database]
(let [table (hydrate (db/select-one Table :db_id (u/get-id database)) :fields)]
(set
(map :name (:fields table)))))))
;; make sure that inactive columns don't end up getting spliced into queries! This test arguably belongs in the query
;; processor tests since it's ultimately checking to make sure columns marked as `:active` = `false` aren't getting
......
......@@ -2,6 +2,7 @@
"Code for creating / destroying an H2 database from a `DatabaseDefinition`."
(:require [clojure.string :as s]
[metabase.db.spec :as dbspec]
metabase.driver.h2 ; because we import metabase.driver.h2.H2Driver below
[metabase.test.data
[generic-sql :as generic]
[interface :as i]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment