Supressing irrelevant code, i've the following:
% somefile.erl
-record(task, {description, date, completed = false}).
init() ->
{atomic, _} = mnesia:create_table(task, [{attributes, record_info(fields, task)}]).
In other file, where the {aborted, {bad_type, {}}}
is ocurring:
-record(task, {id, description, date, completed = false}).
create_task(Req, State) ->
Task = create_task_record(),
Transaction = fun() -> mnesia:write(task, Task, write) end,
{atomic, _} = mnesia:transaction(Transaction),
% ...
When i'm running the code, in the line {atomic, _} = mnesia:transaction(Transaction)
, i'm receiving the error {aborted, {bad_type, {task, ...}}}
.
After hours trying to find, the problem here is in the record task
definition. I wasn't using the hrl
to share definitions, so i have the definition where i was using it, because of this, in one file the definition was missing the id
attribute, so i was having different types.