Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert! returns differently between models #32

Open
hawarir opened this issue Jan 26, 2018 · 1 comment
Open

insert! returns differently between models #32

hawarir opened this issue Jan 26, 2018 · 1 comment

Comments

@hawarir
Copy link

hawarir commented Jan 26, 2018

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?

@camsaul
Copy link
Member

camsaul commented May 16, 2018

Hi @hawari17 unfortunately Toucan still makes assumptions that models have a primary key named :id which of course is not true for everybody. See issue #3.

If you have some spare cycles I would happily merge a PR to improve support for situations like the one you're running in to!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants