#1 2024-08-15 10:38:59

mormoter
Member
Registered: 2024-06-14
Posts: 20

A simple error I met,but i cannot make it.

A rest orm server:

   server:  TserRestServerDB

   client:TRESTHttpClient

   model:TOrmBiolife = class(TOrm)

 
client:
    Rec := TOrmBiolife.Create;
  try
    Rec.Species_No := strtoint(NameEdit.Text);
    Rec.Category:='test';
    rec.Common_Name:='testname';
    id:= Database.Add(rec,true,true,false);   //failed to add,why ?   

server log is :
20240815 10053656  -    00.000.681
20240815 10054513  +    mormot.rest.sqlite3.TSqlRestServerDB(016560a0).URI POST lqf/Biolife in=120 B
20240815 10054513 EXC           ESqlite3Exception {Message:"Error SQLITE_CONSTRAINT (19) [Step] using 3.44.2 - NOT NULL constraint failed: BIOLIFE.ID, extended_errcode=1299",ErrorCode:19,SQLite3ErrorCode:"secCONSTRAINT"} [HttpSrv 8080lqf THttpApiSrv] at 010063f39d

Isnt  the Table id controlled by RestServer? I am confused,  can anyone help me ? thank you

Offline

#2 2024-08-15 11:57:52

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

Re: A simple error I met,but i cannot make it.

Check your parameters.

You specified ForceID=true so the ORM tries to use the current value in Rec, which is 0.

Please read the documentation on any doubt:

    // - if ForceID is true, client sends the Value.ID field to use this ID for
    // adding the record (instead of a database-generated ID)

Offline

#3 2024-08-15 12:56:29

mormoter
Member
Registered: 2024-06-14
Posts: 20

Re: A simple error I met,but i cannot make it.

I tried various value for these params , the error is always same .
e.m : id:= Database.Add(rec,true);
In this case,the forceID default value is false ,but the error is same.

Offline

#4 2024-08-15 13:57:40

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

Re: A simple error I met,but i cannot make it.

Try to debug a little on the server side, and see what is wrong.

Offline

Board footer

Powered by FluxBB