First of all... you didn't do an ApplyUpdates after the Delete action in BeforeDelete for the detailset. So actually all the cars are kept in the dataset but aren't visible because the person is deleted (although restarting your app these persons will be visible again because you don't do ApplyUpdates there too). The records are only really deleted when you do the Applyupdates.
Then, when there are no visible records in the person-dataset, the filter for master/detail is de-activated. You can see that in this code in CustomSqliteDS.pas (the
"(FMasterLink.Dataset.RecordCount = 0)" part).
begin
if not FMasterLink.Active or (FMasterLink.Dataset.RecordCount = 0) then //Retrieve all data
FEffectiveSQL := FSqlFilterTemplate
else
AFilter := ' where ';
for i := 0 to FMasterLink.Fields.Count - 1 do
//...
It is debatable if this check "(FMasterLink.Dataset.RecordCount = 0)" should be there (I don't think it should). But the fact remains that if the master-dataset doesn't have records the detail-dataset shouldn't have records either (usually). And in your case it does (because of the missing ApplyUpdates).
(B.T.W. All this could have been avoided if you used foreign keys and the constraint ON DELETE CASCADE, but that aside
)