#1 2023-03-26 08:51:39

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

CSV, TFieldBits, Retrieve, Update and RowID

I noticed the following when trying to retrieve orm instances:

I am using the Retrieve:
function Retrieve(const SqlWhere: RawUtf8; Value: TOrm; const aCustomFieldsCsv: RawUtf8 = ''): boolean;

When defining custom return of fileds in aCustomFieldsCsv, the RowID must be included in order to be returned.

In the following function, if RowID is included in CustomCsvFields then the update call fails:
function Update(Value: TOrm; const CustomCsvFields: RawUtf8; DoNotAutoComputeFields: boolean): boolean;

When using TFieldBits, ID/RowID is not included and it is manipulated separately.
The following function helps also not to have an error if included in the input string:
function FieldBitsFromCsv(const aFieldsCsv: RawUtf8; var Bits: TFieldBits; out withID: boolean): boolean;

I surely understand that in an update nobody will include the RowID to be updated, but in Retrieve this difference it is not clear in the documentation
My proposal, is not to change anything in the code. Just include in the Retrieve's comments (to be included in the future in the documentation) that as aCustomFieldsCsv is injected directly in the Select query, RowID must be included if needed.

Last edited by dcoun (2023-03-26 08:53:41)

Offline

#2 2023-03-27 14:56:55

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

Re: CSV, TFieldBits, Retrieve, Update and RowID

Please check https://github.com/synopse/mORMot2/commit/688c4396

I hope it helps to resolve any such problem.

Offline

Board footer

Powered by FluxBB