If you have default values set in your database, then Repo.insert
will not return its value.
To return the value, you have to pass Repo.insert(returning: true)
If you dont want to do returning: true
you can set default return value in your schema.
schema "rooms" do
field :enable_chat, :boolean, default: false
end
Then when you do insert, it will return the default false
Top comments (2)
That's a cool tidbit of info.
So, does this also count for auto-increment IDs then?
By default, primary key typically :id are returned without even using
returning: true
.