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
Assume all h2 tables are writable (#62485)
Ngoc Khuat9fcc08fc3a46
diff --git a/e2e/support/cypress_data.js b/e2e/support/cypress_data.jsindex 9cd66775bbf..4719d1a0f66 100644--- a/e2e/support/cypress_data.js+++ b/e2e/support/cypress_data.js@@ -27,15 +27,15 @@ export const SAMPLE_DB_SCHEMA_ID = "1:PUBLIC";// so any changes that affect the order of the tables returned by that function will change the ids of these tables. A common case is when adding a new key to table metadataexport const SAMPLE_DB_TABLES = {// old tables- STATIC_PRODUCTS_ID: 3,- STATIC_ORDERS_ID: 4,- STATIC_PEOPLE_ID: 6,- STATIC_REVIEWS_ID: 8,+ STATIC_PRODUCTS_ID: 7,+ STATIC_ORDERS_ID: 1,+ STATIC_PEOPLE_ID: 2,+ STATIC_REVIEWS_ID: 5,// new tables- STATIC_ACCOUNTS_ID: 5,- STATIC_ANALYTIC_EVENTS_ID: 2,- STATIC_FEEDBACK_ID: 7,- STATIC_INVOICES_ID: 1,+ STATIC_ACCOUNTS_ID: 8,+ STATIC_ANALYTIC_EVENTS_ID: 4,+ STATIC_FEEDBACK_ID: 3,+ STATIC_INVOICES_ID: 6,};// All users and admin groups are the defaults that come with Metabase.diff --git a/e2e/test/scenarios/dashboard-cards/click-behavior.cy.spec.js b/e2e/test/scenarios/dashboard-cards/click-behavior.cy.spec.jsindex 1cd98b751d2..f5461ef3812 100644--- a/e2e/test/scenarios/dashboard-cards/click-behavior.cy.spec.js+++ b/e2e/test/scenarios/dashboard-cards/click-behavior.cy.spec.js@@ -2191,12 +2191,12 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {],expressions: ["Net"],filters: [- "Product → Title is Doohickey",- "Reviews - Product → Reviewer is Doohickey",- "ID is 7021",+ "User → Longitude is equal to -80","Net is equal to -80",+ "ID is 7021",+ "Reviews - Product → Reviewer is Doohickey","Product → Vendor is Doohickey",- "User → Longitude is equal to -80",+ "Product → Title is Doohickey",],aggregations: ["Count", "Sum of Total"],breakouts: [diff --git a/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js b/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.jsindex 3aa686bc0dd..0bb4540f697 100644--- a/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js+++ b/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js@@ -2415,8 +2415,8 @@ describe("issue 50038", () => {strategy: "left-join",condition: ["=",- ["field", ORDERS_ID, {}],- ["field", PRODUCTS_ID, {}],+ ["field", PRODUCTS.ID, null],+ ["field", ORDERS.PRODUCT_ID, { "join-alias": "Orders" }],],},],diff --git a/src/metabase/driver/h2.clj b/src/metabase/driver/h2.cljindex 527f405e973..bf3aea6e930 100644--- a/src/metabase/driver/h2.clj+++ b/src/metabase/driver/h2.clj@@ -542,7 +542,9 @@(defmethod sql-jdbc.sync/active-tables :h2[& args]- (apply sql-jdbc.sync/post-filtered-active-tables args))+ ;; HACK: we assume that all h2 tables are writable+ (eduction (map #(assoc % :is_writable true))+ (apply sql-jdbc.sync/post-filtered-active-tables args)))(defmethod sql-jdbc.sync/excluded-schemas :h2[_]diff --git a/test/metabase/driver/sql_jdbc/sync/describe_database_test.clj b/test/metabase/driver/sql_jdbc/sync/describe_database_test.cljindex 2a629984b58..2ad77cf6ef6 100644--- a/test/metabase/driver/sql_jdbc/sync/describe_database_test.clj+++ b/test/metabase/driver/sql_jdbc/sync/describe_database_test.clj@@ -86,14 +86,14 @@sort))))))(deftest describe-database-test- (is (= {:tables #{{:name "USERS", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "VENUES", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "CATEGORIES", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "CHECKINS", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "ORDERS", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "PEOPLE", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "PRODUCTS", :schema "PUBLIC", :description nil, :is_writable nil}- {:name "REVIEWS", :schema "PUBLIC", :description nil, :is_writable nil}}}+ (is (= {:tables #{{:name "USERS", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "VENUES", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "CATEGORIES", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "CHECKINS", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "ORDERS", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "PEOPLE", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "PRODUCTS", :schema "PUBLIC", :description nil, :is_writable true}+ {:name "REVIEWS", :schema "PUBLIC", :description nil, :is_writable true}}}(sql-jdbc.describe-database/describe-database :h2 (mt/id)))))(defn- describe-database-with-open-resultset-count!diff --git a/test/metabase/driver/sql_jdbc_test.clj b/test/metabase/driver/sql_jdbc_test.cljindex 6804212bb5a..2e664828072 100644--- a/test/metabase/driver/sql_jdbc_test.clj+++ b/test/metabase/driver/sql_jdbc_test.clj@@ -24,7 +24,7 @@(deftest ^:parallel describe-database-test(is (= {:tables (set (for [table ["CATEGORIES" "VENUES" "CHECKINS" "USERS" "ORDERS" "PEOPLE" "PRODUCTS" "REVIEWS"]]- {:name table, :schema "PUBLIC", :description nil, :is_writable nil}))}+ {:name table, :schema "PUBLIC", :description nil, :is_writable true}))}(driver/describe-database :h2 (mt/db)))))(deftest describe-fields-sync-with-composite-pks-testdiff --git a/test/metabase/warehouse_schema/api/table_test.clj b/test/metabase/warehouse_schema/api/table_test.cljindex 280b0d885de..26cb33eea85 100644--- a/test/metabase/warehouse_schema/api/table_test.clj+++ b/test/metabase/warehouse_schema/api/table_test.clj@@ -57,17 +57,20 @@:provider_name nil:is_audit false}))-(defn- table-defaults []- (merge- (update (mt/object-defaults :model/Table) :data_authority name)- {:db (db-details)- :db_id (mt/id)- :entity_type "entity/GenericTable"- :field_order "database"- :view_count 0- :metrics []- :segments []- :is_writable nil}))+(defn- table-defaults+ ([]+ (table-defaults (or driver/*driver* :h2)))+ ([driver]+ (merge+ (update (mt/object-defaults :model/Table) :data_authority name)+ {:db (db-details)+ :db_id (mt/id)+ :entity_type "entity/GenericTable"+ :field_order "database"+ :view_count 0+ :metrics []+ :segments []+ :is_writable (or (= driver :h2) nil)})))(defn- field-defaults [](merge@@ -161,7 +164,7 @@(deftest ^:parallel get-table-test(testing "GET /api/table/:id"(is (= (merge- (dissoc (table-defaults) :segments :field_values :metrics)+ (dissoc (table-defaults :h2) :segments :field_values :metrics)(t2/hydrate (t2/select-one [:model/Table :id :created_at :updated_at :initial_sync_status:view_count]:id (mt/id :venues))@@ -190,7 +193,8 @@{:schema "":name "schemaless_table":display_name "Schemaless"- :db_id database-id})+ :db_id database-id+ :is_writable nil})(dissoc (mt/user-http-request :rasta :get 200 (str "table/" table-id)):db)))))))@@ -443,7 +447,8 @@:entity_type nil:schema "":visibility_type "hidden"- :display_name "Userz"})+ :display_name "Userz"+ :is_writable nil})(dissoc (mt/user-http-request :crowberto :get 200 (format "table/%d" (u/the-id table))):updated_at))))))@@ -639,7 +644,7 @@;; Index sync is turned off across the application as it is not used ATM.#_#_:database_indexed true:table (merge- (dissoc (table-defaults) :db :segments :field_values :metrics)+ (dissoc (table-defaults :h2) :db :segments :field_values :metrics)(t2/select-one [:model/Table:id :created_at :updated_at:initial_sync_status :view_count]