#1 2015-05-17 15:25:52

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 330

negativ IDs

After inserting a negativ ID in a table with something like this:

R:= TSQLHV.Create;
R.IDValue:= -1;
DB.Add(R, true, true);

I try to delete the inserted record with:

DB.Delete(TSQLHV, -1);

but nothing happened, because of

if (ID<=0) or (TableModelIndex<0) or (Model.Tables[TableModelIndex]<>fStoredClass) then

in mORMot.pas line 1202?

Offline

#2 2015-05-17 18:17:35

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

Re: negativ IDs

A negative ID is interpreted as an error code, in most part of the code.

This is not consistent, but, in practice, you should NOT use negative IDs.
Even if they are allowed by SQLite3 or other means of storage, of course.

They are in fact reserved for future use.
I would like to use them for TSQLRestBatch automatic replacement of created IDs, e.g. when adding nested records (a record referencing to a previous one, just inserted during the very same batch, so not known in advance).

Offline

Board footer

Powered by FluxBB