#1 2012-12-18 16:34:58

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

TSQLRestClient.Add(Rec, true, true) does not work

Trying to add records with an pre-filled ID, by calling

  TSQLRestClient.Add(Rec, true, true);

But they are still inserted with a ID generated by a call to EngineLockedNextID.

Probable cause, the following line (MormotDB.pas, line 864) is always used when not in Batch mode

    result := ExecuteFromJSON(SentData,0); // UpdatedID=0 -> insert with EngineLockedNextID

Callstack:

Mormot_D17.mORMot.TJSONObjectDecoder.Decode('"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}',(),pNonQuoted,7,True)
Mormot_D17.mORMot.TJSONObjectDecoder.Decode('{"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}',(),pNonQuoted,7,True)
Mormot_D17.mORMotDB.TSQLRestServerStaticExternal.ExecuteFromJSON('{"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}',0)
Mormot_D17.mORMotDB.TSQLRestServerStaticExternal.EngineAdd(TSQLUnitTestSampleRecord,'{"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}')
Mormot_D17.mORMot.TSQLRestServer.URI($18F318)
Mormot_D17.mORMotSQLite3.TSQLRestClientDB.InternalURI('root/UnitTestSampleRecord','POST',nil {''},$18F3F0 {''},$18F3FC {'{"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}'})
Mormot_D17.mORMot.TSQLRestClientURI.URI('root/UnitTestSampleRecord','POST',nil {''},$18F3F0 {''},$18F3FC {'{"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}'})
Mormot_D17.mORMot.TSQLRestClientURI.EngineAdd(TSQLUnitTestSampleRecord,'{"RowID":720,"ModTime":135071471049,"Name":"PietjePuck 7","Question":"{80722197-6E21-494F-A8E3-423B42A4A168}","Address_":"Parklaan 23","PostalCode":"2347BC","City":"Nuenen","Datum":"2012-05-07","FloatNumber":7,"IntNumber":2147490647,"CurrencyNumber":255.70}')
Mormot_D17.mORMot.TSQLRestClient.Add($25C4E30,True,True)

Last edited by Bascy (2012-12-18 20:40:42)

Offline

#2 2013-01-02 08:44:10

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

Re: TSQLRestClient.Add(Rec, true, true) does not work

Any progress on this?

Offline

#3 2013-01-02 09:30:19

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

Re: TSQLRestClient.Add(Rec, true, true) does not work

Could you please create a ticket for easiest follow-up?

http://synopse.info/fossil/reportlist
(you need to be logged, even as anonymous, to create a ticket)

Offline

#4 2013-01-02 10:33:54

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

Re: TSQLRestClient.Add(Rec, true, true) does not work

Done

Offline

#5 2013-01-07 09:33:09

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

Re: TSQLRestClient.Add(Rec, true, true) does not work

Any progress on ticket 3c4146259476d06c76e5850f522ea3d093f89355?

Offline

#6 2013-01-14 16:24:32

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

Re: TSQLRestClient.Add(Rec, true, true) does not work

I've committed a potential fix.

Some refactoring was necessary, since "force ID" feature was broken in several cases, including your external table process.
Even TSQLRestServerDB.EngineAdd() and TSQLRestServerStaticInMemory.AddOne() will now handle forced ID in sent data.

See http://synopse.info/fossil/info/ec93593d5e

Offline

#7 2017-06-16 11:58:11

houdw2006
Member
Registered: 2015-05-23
Posts: 48

Re: TSQLRestClient.Add(Rec, true, true) does not work

Hi, @ab, I think some refactoring is also necessary for function TSQLRestStorageInMemory.AddOne(Rec: TSQLRecord; ForceID: boolean;
  const SentData: RawUTF8): TID;.  If the new come rec is out of order and ForceID is true,  there whole table will be sorted. If a lot of new come recs all like this, the sorting would take quite a long time. 

I think perhaps some flags can be added such as BeginUpdate ... EndUpdate, to control the sorting procedure to take place or not.

Offline

#8 2017-06-16 12:26:17

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

Re: TSQLRestClient.Add(Rec, true, true) does not work

If you are about to force the ID, then switch to the regular SQlite3 engine, not use TSQLRestStorageInMemory, which has indeed its limitations.

Offline

Board footer

Powered by FluxBB