You are not logged in.
I am using with Mormot2 the following function in a table with TRestStorageInMemory type storage
function TRestOrm.MultiFieldValue(Table: TOrmClass;
const FieldName: array of RawUtf8; var FieldValue: array of RawUtf8;
const WhereClause: RawUtf8): boolean;
I noticed that the order of FieldValue results do not follow the FieldName fields order but the fields' order in the table definition.
Offline
If we do not know the table definition, Is it possible somehow to get the fieldname of each result returned?
I used the ExecuteJson and parse it with _json(json,variant,JSON_FAST) as alternative
Do you recommend an other function?
Last edited by dcoun (2021-12-23 13:40:08)
Offline
Oh you are right: for MultiFieldValue it is confusing.
I will fix it.
Edit: Please check https://github.com/synopse/mORMot2/commit/35583c64
Offline
Oh you are right: for MultiFieldValue it is confusing.
I will fix it.Edit: Please check https://github.com/synopse/mORMot2/commit/35583c64
I tested requesting 7 fields from a table with 72 fields.
As they exist in table definition: RowID, field1, field2, field3, field4, field5, field6
As requested: RowID, field1, field4, field6, field2, field3, field5
as received: RowID, field1, field4, field5, field2, field6, field3
Offline
I think the code in mormot.orm.rest line 908 should be like the following:
// get field values from the first (and unique) row
for f := 0 to T.FieldCount - 1 do
begin
i := f; // regular SQL SELECT order by default
if (T.FieldCount > 1) and
(StrIComp(T.Results[i], pointer(FieldName[i])) <> 0) then
begin
// not the regular order (e.g. TRestStorageInMemory = TOrm order)
i := T.FieldIndex(FieldName[f]);
if i < 0 then
if not IsFieldName(pointer(FieldName[f])) then
exit // something went wrong
else
i := f; // expects the function results to be in-order
end;
o := i + T.FieldCount;
FastSetString(FieldValue[f], T.Results[o], T.ResultsLen[o]);
end;
The above code works
Offline
Offline
@ab,
Thank you again for your work and the people that contribute
Merry Christmas, Happy Year, seasonal wishes to all
Offline