I have a weird issue in Ecto with boolean field in changeSets. Suppose I have:
def changeset(%MyTable{} = table, attrs) do
table
|> change(attrs)
end
Then the following
%MyTable{id: id}
|> MyTable.changeset({my_boolean?: true})
produces a valid changeset
where the field my_boolean?
is set to true. But the following:
%MyTable{id: id}
|> MyTable.changeset({my_boolean?: false})
produces a valid empty changeset
. Like that I would say that it seems to be a bug. Maybe
if map[field] ...
is used somewhere in the code to check if field
is a field of map
(instead of using if map[field] != nil
). Maybe I miss something and it is not a bug.
Anyone knows what I can do to be able to create ChangeSets with boolean fields set to false ?