Daniele Teti 2021-08-15 16:39:41 +02:00
parent fe5c92f069
commit 07805a80ac
2 changed files with 50 additions and 0 deletions

View File

@ -553,6 +553,7 @@ This version introduced new features in many different areas (swagger, server si
- Fix https://github.com/danieleteti/delphimvcframework/issues/461
- Fix https://github.com/danieleteti/delphimvcframework/issues/489 (thanks to [drcrck](https://github.com/drcrck) for his initial analisys)
- Fix https://github.com/danieleteti/delphimvcframework/issues/493 (thanks to [DelphiMan68](https://github.com/DelphiMan68) for his initial analisys)
- Fix https://github.com/danieleteti/delphimvcframework/issues/451
- Fix for nil objects in lists during serialization
- Uniformed behavior in `Update` and `Delete` method in `TMVCActiveRecord`. Now these methods raise an exception if the record doesn't exists anymore in the table (update or delete statements return `AffectedRows` = 0). The behavior can be altered using the new parameter in the call, which by default is `true`. WARNING! This change could raise some incompatibilities with the previous version, however this is the correct behavior. Consider the previous one a "incorrect behavior to fix".
- Fix https://github.com/danieleteti/delphimvcframework/issues/489

View File

@ -50,6 +50,8 @@ type
[Test]
procedure TestCRUD;
[Test]
procedure Test_ISSUE485;
[Test]
procedure TestDeleteIfNotFound;
[Test]
procedure TestUpdateIfNotFound;
@ -816,6 +818,53 @@ begin
end;
end;
procedure TTestActiveRecordBase.Test_ISSUE485;
var
lCustomer: TCustomer;
lID: Integer;
begin
Assert.AreEqual(Int64(0), TMVCActiveRecord.Count<TCustomer>());
lCustomer := TCustomer.Create;
try
lCustomer.CompanyName := 'bit Time Professionals';
lCustomer.City := 'Rome, IT';
lCustomer.Note := 'note1';
lCustomer.CreationTime := Time;
lCustomer.CreationDate := Date;
lCustomer.ID := -1; { don't be fooled by the default! }
lCustomer.Insert;
lID := lCustomer.ID;
Assert.AreEqual(1, lID);
finally
lCustomer.Free;
end;
lCustomer := TMVCActiveRecord.GetByPK<TCustomer>(lID);
try
Assert.IsTrue(lCustomer.CompanyName.HasValue);
lCustomer.CompanyName.Clear;
lCustomer.Update;
finally
lCustomer.Free;
end;
lCustomer := TMVCActiveRecord.GetByPK<TCustomer>(lID);
try
Assert.IsFalse(lCustomer.CompanyName.HasValue);
lCustomer.CompanyName := 'bit Time Professionals';
lCustomer.Update;
finally
lCustomer.Free;
end;
lCustomer := TMVCActiveRecord.GetByPK<TCustomer>(lID);
try
Assert.IsTrue(lCustomer.CompanyName.HasValue);
finally
lCustomer.Free;
end;
end;
procedure TTestActiveRecordBase.InternalSetupFixture;
begin
// do nothing