#1 2012-05-17 22:22:50

yurasek
Member
From: Belarus
Registered: 2011-04-19
Posts: 18

Additional method of TSQLRestClient.Update

It seems to me, TSQLRestClient is lacking such method as

function TSQLRestClient.Update(Value: TSQLRecord; ID: integer): boolean; override;

Sometimes it is necessary to update the ID for the record, and this method would be useful.

Offline

#2 2012-05-18 07:37:54

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

Re: Additional method of TSQLRestClient.Update

From the ground up, the ID of a record is supplied by the framework, in fact by the underneath DB layer.
Some features (like caching or DB integrity) relies on it.
Updating an ID is something which is not implemented yet - but it is on purpose.

For instance, in a Domain Driven architecture, AFAIK the ID of an Entity object is unique, and identifies it.
In short, ID attribution is part of the low-level object management and DB layer, not part of the business layer.

From the RESTful point of view, I did not see any way of updating an ID for an existing item.
How would be the URI layered, in this case?

Why do you want to "update" the ID?
You should better create a new object with a new ID, then use it.

Offline

#3 2012-05-18 07:38:08

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Additional method of TSQLRestClient.Update

Updating ID ( primary key) from client app - it seems like architecture problem. Updating ID usually need some additional steps like: lock tables; disable constraints; change ID; change  value of fields what foreign key on this ID; check integrity; enable constraints; The best way is not to update primary key.

Offline

#4 2012-05-18 09:06:38

yurasek
Member
From: Belarus
Registered: 2011-04-19
Posts: 18

Re: Additional method of TSQLRestClient.Update

ab, mpv, you are absolutely right. I wanted to save by using the field ID, but as I understand it better and more correct to add a new field. Thank you.

Offline

Board footer

Powered by FluxBB