You are not logged in.
Pages: 1
in my database my records are with RackId field filled with null
my class TAmostra has property RackID: TNullableInteger read FRackID write FRackID;
var
vListaAmostras: IDocList;
vAmostra: IDocObject;
vTempAmostra: TAmostra;
begin
vTempAmostra := TAmostra.Create;
try
vListaAmostras := DocListFrom(FRestOrm.Orm.RetrieveDocVariantArray(TAmostra, '', '(SolicitacaoID=?)', [pSolicitacaoExistenteId], '*'));
for vAmostra in vListaAmostras do
begin
vTempAmostra.FillFrom(Variant(vAmostra.Value^));
if (Pos(vTempAmostra.Numero, pAmostras) <> 0)
or not NullableIntegerIsEmptyOrNull(vTempAmostra.RackID) then
Continue;
...
NullableIntegerIsEmptyOrNull(vTempAmostra.RackID) return false when shoul be return true.
debugging i see that vListaAmostras[0] return
'{"ID":26,"datacriacao":"2025-01-07T11:32:17","ultimaalteracao":"2025-01-07T11:42:47","empresaid":1,"numero":"0101","solicitacaoid":12,"exames":"PC, FOS","dataetiqueta":"2022-09-03T10:12:34","rackid":0,"linha":0,"coluna":0,"coletado":false,"cancelada":true,"postoatualid":1}'
should be "rackid": null????? because in database is null
Offline
TSqlDBStatement.FetchAllToJson return "rackid":null
'{"id":32,"datacriacao":"2025-01-13T09:58:46","ultimaalteracao":"2025-01-13T09:58:46","empresaid":1,"numero":"0101","solicitacaoid":12,"exames":"PC, FOS","dataetiqueta":"2022-09-03T10:12:34","rackid":null,"linha":0,"coluna":0,"coletado":0,"cancelada":0,"postoatualid":1}'
function TRestOrm.RetrieveDocVariantArray(Table: TOrmClass;
const ObjectName: RawUtf8; const FormatSqlWhere: RawUtf8;
const BoundsSqlWhere: array of const; const FieldsCsv: RawUtf8;
FirstRecordID, LastRecordID: PID): variant;
...
T := MultiFieldValues(Table, FieldsCsv, FormatSqlWhere, BoundsSqlWhere);
if T <> nil then
try
T.ToDocVariant(v, {readonly=}false); <<<<<<<<<<<< this part change "rackid":null of database to "rackid":0 (ZERO)
v = > '[{"ID":32,...,"rackid":0,...},...}]'
if FirstRecordID <> nil then
FirstRecordID^ := T.GetID(1);
...
Last edited by mrbar2000 (2025-01-17 13:32:44)
Offline
Should be better with
https://github.com/synopse/mORMot2/commit/4028967a5
Note that I made a huge code refactoring of the ORM core about those null values.
Some other commits to consider.
Online
Pages: 1