TBufDataset: filter doesn't handle LargeInt fields.
Summary
System Information
- Operating system: Windows 10
- Processor architecture: x86-64
- Compiler version: 3.2.2, trunk
- Device: Laptop
Steps to reproduce
Run attached project
Example Project
program a;
{$mode objfpc}{$H+}
uses
Classes,
SysUtils,
DB,
BufDataset, bufdataset_parser, dbf_prscore;
var
Fdb: TBufDataset;
begin
Fdb := TBufDataset.Create(nil);
Fdb.FieldDefs.Add('prjid', ftLargeint);
Fdb.FieldDefs.Add('no', ftString, 10);
Fdb.CreateDataset;
Fdb.AppendRecord([0, '0']);
Fdb.AppendRecord([High(Int64), '1']);
Fdb.AppendRecord([3556856671915480078, '2']); // ~bk is within range of ftLargeInt
Fdb.AppendRecord([3556856671915480017, '3']);
Fdb.AppendRecord([-32767, '4']); // ~bk is within range of ftLargeInt
WriteLn('RecordCount=', Fdb.RecordCount, ' UNFILTERED');
with Fdb do begin
First;
while not EOF do begin
WriteLn(FieldByName('prjid').AsString, ' ', FieldByName('no').AsString: 4);
Next;
end;
end;
Fdb.Filter := 'prjid=-32767 or prjid=3556856671915480078'; // 'prjid=0' -> works
WriteLn('Filtered with ''', Fdb.Filter, '''');
Fdb.Filtered := True;
with Fdb do begin
First;
while not EOF do begin
WriteLn(FieldByName('prjid').AsString, ' ', FieldByName('no').AsString: 4);
Next;
end;
end;
ReadLn;
end.
What is the current bug behavior?
RecordCount=5 UNFILTERED
0 0
9223372036854775807 1
3556856671915480078 2
3556856671915480017 3
-32767 4
Filtered with 'prjid=-32767 or prjid=3556856671915480078'
-32767 4
What is the expected (correct) behavior?
RecordCount=5 UNFILTERED
0 0
9223372036854775807 1
3556856671915480078 2
3556856671915480017 3
-32767 4
Filtered with 'prjid=-32767 or prjid=3556856671915480078'
3556856671915480078 2
-32767 4
Possible fixes
Proposed patch on trunk dbf_prscore.diff