You are not logged in.
Pages: 1
I am trying to use the following code:
var b:boolean=true;
bi:TFieldBits=ALL_FIELDS;
ee:TormMyclass
begin
ee.GetJsonValues(true,b,bi);
I am getting exception in TResultsWriter.AddColumns(aKnownRowsCount: integer);
in line 2824:
len := PStrLen(PAnsiChar(c^) - _STRLEN)^; // ColNames[] <> ''
Colnames is:
('"RowID":', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'yid', 'erid', 'dat', 'rid', 'xxID', 'typ', 'person', 'sim', 'pd', 'uvd', 'aym', 'ser', 'endata', 'uFdata', 'user')
Thank you in advance
Offline
Too many fields. You have to define MAX_SQLFIELDS_128.
With best regards
Thomas
Offline
Empty fields are not mine.
MAX_SQLFIELDS_128 is set for other torms
Offline
Mariadb is used as database
ID, 'yid', 'erid', 'dat', 'rid', 'xxID', 'typ', 'person', 'sim', 'pd', 'uvd', 'aym', 'ser', 'endata', 'uFdata', 'user' are correctly the published TormMyclass's properties, the same for table's fields
the ee object has ok its data resulting from a Torm.retrieve
I believe the problem is in mormot.orm.base TOrmPropertiesAbstract.SetJsonWriterColumnNames(W: TOrmWriter; KnownRowsCount: integer);
n := ord(W.withID); produces a n with value 64
Offline
procedure TOrmPropertiesAbstract.SetJsonWriterColumnNames(W: TOrmWriter; KnownRowsCount: integer);
var
i, n, nf: PtrInt;
begin
// set col names
nf := Length(W.Fields); -->15
n := ord(W.withID); -->64
SetLength(W.ColNames, nf + n);
if W.withID then
W.ColNames[0] := ROWID_TXT; // works for both normal and FTS3 records
for i := 0 to nf - 1 do -->
begin
W.ColNames[n] := Fields.List[W.Fields[i]].Name;
inc(n);
end;
// write or init field names for appropriate JSON Expand
W.AddColumns(KnownRowsCount); -->KnownRowsCount=0
end;
At the end n=79
I have above the values, the variables get
Offline
Changing
n := ord(W.withID);
to
n := ord(integer(W.withID)<>0);
works OK
Delphi 11.3 32bit
Offline
The problem was finally in my code. The provided variable b content was the problem
Apologies for the trouble
Last edited by dcoun (2023-10-20 08:49:43)
Offline
The problem was finally in my code. The provided variable b content was the problem
Apologies for the trouble
Can you please describe exactly what you did wrong and how you solved it, so that other readers can find a solution here if they have the same problem. You can also learn from mistakes and you don't have to make them all yourself. I have no idea what exactly went wrong for you.
With best regards
Thomas
Offline
Sure, it was very stupid of myself
b is a local variable inside a rest function. b is used in a TOrmmyclass.OrmProps.FieldBitsFromCsv(bity,bi,b) to set what fields will be retrieved.
In one special case inside the algorithm b was not initialized and for a reason I can not understand all the times the function was used, it got the value 64.
The above value as boolean was shown as true and only if you try to transform it to integer, this value is shown
Finding this case's missing initialization, and set the initial value to true, it was fixed.
Offline
Even if the problem rooted in your code, the framework should be able to manage wrong input.
Offline
Pages: 1