metabase / metabase/toucan

insert! returns differently between models

Open
#32 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
576
Forks
48
PR merge metrics
No merged PRs in 30d

Description

Hi, so I have two models here, lets say one is Model A and the other one is Model B. When I `insert!` Model A, the function returns its identity, but when I `insert!` Model B, the returned value is nil.

The difference between this model is that Model A is using generated id from mysql, where Model B is using id composed in my application:
```
(defmodel B :b
IModel
(pre-insert [payload]
(assoc payload
:id (.toString (java.util.UUID/randomUUID))))

=> (insert! A {:name "John Doe" :email "john@doe.com"}
#AInstance{:id 1 :name "John Doe" :email "john@doe.com"}

=> (insert! B {:name "John Doe" :email "john@doe.com"}
nil
```
Is this behavior expected?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the insert! entry point and compare its handling of Model A's generated MySQL id with Model B's application-assigned UUID from pre-insert. Reproduce both examples, then trace the return-value path; done means the behavior is explained and the issue's expected result is documented or covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.