You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Postgresql
The following code never succeeds unless there's a 'counters' table in the database:
F=fun() ->
%% some other things that will allways be rolled backboss_db:delete("model-1"); %%never gets deleted, gets rolled back, but returns okboss_db:delete("model-2"); %%throws an exception about rolled back transactionend,
boss_db:transaction(F)
the same code outside of tranaction works
boss_db:delete("model-1"); %%succeeds
The reason is the function delete:
delete(Conn, Id) whenis_list(Id) ->
{_, TableName, IdColumn, TableId} =boss_sql_lib:infer_type_from_id(Id),
Res=pgsql:equery(Conn, ["DELETE FROM ", TableName, " WHERE ", IdColumn, " = $1"], [TableId]),
caseResof
{ok, _Count} ->
pgsql:equery(Conn, "DELETE FROM counters WHERE name = $1", [Id]),
ok;
{error, Reason} -> {error, Reason}
end.
This functions executes the second SQL query which fails and rollbacks the whole transaction.
A result of the second pgsql:equery is ignored so it returns ok every time even then the query fails.
I'm not sure if this should be considered a bug or not.
The text was updated successfully, but these errors were encountered:
Using delete for two different things - deleting records and deleting
keys from the counter table - was causing problems like:
ErlyORM#135
This commit introduces a delete_counter that only deletes keys from
the counter. The delete function only deletes records.
Hrm I always thought that a counters table was compulsory.. and seem to recall reading docs about it. I do remember being bitten by something similiar when I was trying to get up and running. Perhaps it was just the auto-initialisation scripts created them.
This issue should be fixed. To be honest, I feel like that the counters functionality is better off as a separate library/plugin for boss_db, and perhaps make it compulsory if you want to use that plugin.
A workaround for the time being could be to do a table_exists of the counters table when doing a delete, but in no way should this be exposed to the developer that doesn't use counters. I would be willing to address this issue myself, once we reach agreement on what the solution should be.
Postgresql
The following code never succeeds unless there's a 'counters' table in the database:
the same code outside of tranaction works
The reason is the function delete:
This functions executes the second SQL query which fails and rollbacks the whole transaction.
A result of the second pgsql:equery is ignored so it returns ok every time even then the query fails.
I'm not sure if this should be considered a bug or not.
The text was updated successfully, but these errors were encountered: