Skip to content

Commit dafe19b

Browse files
committed
[Linq] fixed issue filter returns more items than expected
1 parent b271c15 commit dafe19b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Quick.Linq.pas

+25
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ function TLinqQuery<T>.Select(const aPropertyName: string): TFlexArray;
371371
if fWhereClause = nil then raise ELinqNotValidExpression.Create('Not valid expression defined!');
372372
for obj in fList do
373373
begin
374+
{$IFNDEF FPC}
375+
if obj = nil then continue;
376+
{$ELSE}
377+
if Pointer(obj) = nil then continue;
378+
{$ENDIF}
374379
if fWhereClause.Validate(obj) then
375380
begin
376381
//value := TRTTI.GetProperty(obj,aPropertyName);
@@ -396,6 +401,11 @@ function TLinqQuery<T>.Select: TxArray<T>;
396401
if fWhereClause = nil then raise ELinqNotValidExpression.Create('Not valid expression defined!');
397402
for obj in fList do
398403
begin
404+
{$IFNDEF FPC}
405+
if obj = nil then continue;
406+
{$ELSE}
407+
if Pointer(obj) = nil then continue;
408+
{$ENDIF}
399409
if fWhereClause.Validate(obj) then Result.Add(obj);
400410
end;
401411
DoOrderBy(Result);
@@ -412,6 +422,11 @@ function TLinqQuery<T>.SelectFirst: T;
412422
if fWhereClause = nil then raise ELinqNotValidExpression.Create('Not valid expression defined!');
413423
for obj in fList do
414424
begin
425+
{$IFNDEF FPC}
426+
if obj = nil then continue;
427+
{$ELSE}
428+
if Pointer(obj) = nil then continue;
429+
{$ENDIF}
415430
if fWhereClause.Validate(obj) then Exit(obj);
416431
end;
417432
end;
@@ -427,6 +442,11 @@ function TLinqQuery<T>.SelectLast: T;
427442
if fWhereClause = nil then raise ELinqNotValidExpression.Create('Not valid expression defined!');
428443
for obj in fList do
429444
begin
445+
{$IFNDEF FPC}
446+
if obj = nil then continue;
447+
{$ELSE}
448+
if Pointer(obj) = nil then continue;
449+
{$ENDIF}
430450
if fWhereClause.Validate(obj) then Result := obj;
431451
end;
432452
end;
@@ -446,6 +466,11 @@ function TLinqQuery<T>.SelectTop(aLimit: Integer): TxArray<T>;
446466
i := 0;
447467
for obj in fList do
448468
begin
469+
{$IFNDEF FPC}
470+
if obj = nil then continue;
471+
{$ELSE}
472+
if Pointer(obj) = nil then continue;
473+
{$ENDIF}
449474
if fWhereClause.Validate(obj) then
450475
begin
451476
Result.Add(obj);

0 commit comments

Comments
 (0)