Hi, I’m seeing an unexpected behavior from UnitOfWork and am hoping to get some assistance.
In summary: Even though a SetRelation operation failed, UnitOfWorkResult’s Success value is true and the UnitOfWork is not rolled back.
More detail:
I’m using a UnitOfWork and setting two BulkCreate operations. After setting each BulkCreate operation, I’m also setting SetRelation operations.
I’m testing a failure case where I expect UnitOfWorkResult’s Success value to be false, because one of the SetRelation operations is designed to fail. That SetRelation operation tries to find its related record in a different table via a “columnName = ‘value’” where-clause, but no such record exists for that clause (by design).
After I execute the UnitOfWork and inspect the UnitOfWorkResult’s Results property, I can see the expected SetRelation failure, where OperationType is SET_RELATION and Result is 0. Also, all of the other operation results look correct.
However the UnitOfWorkResult’s Success value is true and its Error value is null. And via the Backendless Data Browser, I see that a new record was created in the database (via the BulkCreate) and it has a null relation. So the UnitOfWork wasn’t rolled back after the SetRelation error.
Shouldn’t the UnitOfWorkResult’s Success value be false if a SetRelation operation failed? Am I doing something incorrectly or is there an issue?
(I’m using the Backendless .NET SDK version 6.2.0.)
Thanks!