You are not logged in.
mormot.orm.rest, line 1154
T := ExecuteList([Table], SqlFromSelect(Table.SqlTableName,
'ID,' + FieldName, WhereClause, ''));
When using a TrestServerDB the ID needs to be RowID, and as it is now it returns an error
if instead of TrestServerDB, the procedure OneFieldValues runs from a TRestStorageInMemory then the ID is OK
I have noticed it in other functions too: TRestStorageInMemory behaves differently with the RowID/ID that the TrestServerDB, both RowID and ID are accepted in TRestStorageInMemory but thιs is not allowed for TrestServerDB. TrestServerDB returns an error for ID and works only with RowID.
Last edited by dcoun (2022-07-13 15:06:17)
Offline
Isn't this just based on what the chosen database uses for the primary indexed column name in every table? For example, if you're using sqlite then yes you need to use RowID because that's the name of the indexed column, and you only have to do that anyway (AFAIK) if you bypass the ORM layer.
Last edited by pvn0 (2022-07-14 05:24:15)
Offline
In the above situation, the "ID" exists in the mormot2's code and it does not work with any external database that uses sqlite as medium.
RowID works for both as I tested.
Offline
By curiosity only:
Does the following function work for you, when using sqlite/TRestStorageInMemory database without the above correction(RowID instead of ID in line 1154 of mormot.orm.rest)?
function OneFieldValues(Table: TOrmClass; const FieldName, WhereClause: RawUtf8; Strings: TStrings; IDToIndex: PID = nil): boolean; overload;
Thank you in advance
Last edited by dcoun (2022-07-16 08:11:14)
Offline
Please try https://github.com/synopse/mORMot2/commit/22a51995
Note that this issue was passed under the radar: it was 'ID' even on mORMot 1 since years.
I guess this TStrings-oriented method was not very often used.
Offline
Thank you @ab.
It is very helpful if using memory tables to fill automatically comboboxes even with using sqlite's operator || for combobox's options label
Just a line of code for each combo box
I just noticed that when using the operator || you have to named with 'AS' like in the following:
memserver.Orm.OneFieldValues(TOrmtable,'(code || " " || title) as title','SQL condition GROUP BY Rowid',list);
And it fills RowID as Tobject too
Last edited by dcoun (2022-07-16 10:56:18)
Offline