#1 2015-08-05 21:41:35

ASiwon
Member
From: Poland
Registered: 2015-01-30
Posts: 82

TSQLRest.Update question

Hello,

While creating some units test for my classes I found mORMot behaviour which is unexpected to me. When I try to call Update method to update record which does not exists in the database (database in memory for testing purposes) then Update function returns True value. I have expected that it should to return False value in this case. In the documentation exists information: function return true on success but what function should return in the case of update non existing record?


best regards
Adam Siwon

Offline

#2 2015-08-06 06:27:43

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,305
Website

Re: TSQLRest.Update question

This is how SQL works AFAIK.

An UPDATE with a SQL WHERE clause with no match is expected to execute without error.

We may change this behavior for SQLite3 (by using LastChangeCount property), but it would be much more difficult for external SQL, since we can't know if the UPDATE did actually change the data or not.
So IMHO the default behavior is to return TRUE.

You should explicitly run AddOrUpdate() or a previous Retrieve() to check if the record is existing.

Offline

Board footer

Powered by FluxBB