Skip to content
Snippets Groups Projects
Unverified Commit 69f380e6 authored by john-metabase's avatar john-metabase Committed by GitHub
Browse files

Fix v1 dump command error when logging entities (#30463)

Updates v1 dump name-for-logging function to handle Toucan 2 records

Resolves #29322
parent 93701d1b
Branches
Tags
No related merge requests found
......@@ -21,7 +21,8 @@
[metabase.util.schema :as su]
[ring.util.codec :as codec]
[schema.core :as s]
[toucan2.core :as t2]))
[toucan2.core :as t2]
[toucan2.protocols :as t2.protocols]))
(set! *warn-on-reflection* true)
......@@ -338,7 +339,7 @@
(defn name-for-logging
"Return a string representation of entity suitable for logs"
([entity] (name-for-logging (name entity) entity))
([entity] (name-for-logging (t2.protocols/model entity) entity))
([model {:keys [name id]}]
(cond
(and name id) (format "%s \"%s\" (ID %s)" model name id)
......
......@@ -96,3 +96,12 @@
"/databases/Fingerprint test-data copy/schemas/public/tables/users/fields/id"} fq-name))
(is (map? ctx))
(is (some? (:table ctx)))))))))
(deftest name-for-logging-test
(testing "serialization logging name generation from Toucan 2 records (#29322)"
(mt/with-temp* [Collection [{collection-id :id} {:name "A Collection"}]
Card [{card-id :id} {:name "A Card"
:collection_id collection-id}]]
(are [model s id] (= (format s id) (names/name-for-logging (t2/select-one model :id id)))
'Collection ":metabase.models.collection/Collection \"A Collection\" (ID %d)" collection-id
'Card ":model/Card \"A Card\" (ID %d)" card-id))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment