mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 04:29:17 +02:00
* Patch from Ladislav Karrach (Lacak2) to make LocateOptions work for TBufDataset.Locate + test, bug #15725
git-svn-id: trunk@15005 -
This commit is contained in:
parent
aebc2aea40
commit
33f9424d68
@ -532,9 +532,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function DBCompareText(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
function DBCompareText(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if loCaseInsensitive in options then
|
if [loCaseInsensitive,loPartialKey]=options then
|
||||||
|
Result := AnsiStrLIComp(pchar(subValue),pchar(aValue),length(pchar(subValue)))
|
||||||
|
else if [loPartialKey] = options then
|
||||||
|
Result := AnsiStrLComp(pchar(subValue),pchar(aValue),length(pchar(subValue)))
|
||||||
|
else if [loCaseInsensitive] = options then
|
||||||
Result := AnsiCompareText(pchar(subValue),pchar(aValue))
|
Result := AnsiCompareText(pchar(subValue),pchar(aValue))
|
||||||
else
|
else
|
||||||
Result := AnsiCompareStr(pchar(subValue),pchar(aValue));
|
Result := AnsiCompareStr(pchar(subValue),pchar(aValue));
|
||||||
@ -2759,7 +2762,10 @@ begin
|
|||||||
|
|
||||||
SetLength(DBCompareStruct,FieldsAmount);
|
SetLength(DBCompareStruct,FieldsAmount);
|
||||||
for FieldNr:=0 to FieldsAmount-1 do
|
for FieldNr:=0 to FieldsAmount-1 do
|
||||||
|
begin
|
||||||
ProcessFieldCompareStruct(TField(SearchFields[FieldNr]),DBCompareStruct[FieldNr]);
|
ProcessFieldCompareStruct(TField(SearchFields[FieldNr]),DBCompareStruct[FieldNr]);
|
||||||
|
DBCompareStruct[FieldNr].Options:=options;
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
SearchFields.Free;
|
SearchFields.Free;
|
||||||
end;
|
end;
|
||||||
|
@ -38,6 +38,7 @@ type
|
|||||||
procedure TestBookmarkValid;
|
procedure TestBookmarkValid;
|
||||||
|
|
||||||
procedure TestLocate;
|
procedure TestLocate;
|
||||||
|
procedure TestLocateCaseIns;
|
||||||
|
|
||||||
procedure TestFirst;
|
procedure TestFirst;
|
||||||
procedure TestDelete1;
|
procedure TestDelete1;
|
||||||
@ -756,6 +757,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestDBBasics.TestLocateCaseIns;
|
||||||
|
begin
|
||||||
|
with DBConnector.GetNDataset(true,13) do
|
||||||
|
begin
|
||||||
|
open;
|
||||||
|
assertfalse(Locate('name',vararrayof(['TEstName5']),[]));
|
||||||
|
asserttrue(Locate('name',vararrayof(['TEstName5']),[loCaseInsensitive]));
|
||||||
|
AssertEquals(5,FieldByName('id').AsInteger);
|
||||||
|
|
||||||
|
assertfalse(Locate('name',vararrayof(['TestN']),[]));
|
||||||
|
asserttrue(Locate('name',vararrayof(['TestN']),[loPartialKey]));
|
||||||
|
|
||||||
|
assertfalse(Locate('name',vararrayof(['TestNA']),[loPartialKey]));
|
||||||
|
asserttrue(Locate('name',vararrayof(['TestNA']),[loPartialKey, loCaseInsensitive]));
|
||||||
|
close;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestDBBasics.TestSetFieldValues;
|
procedure TTestDBBasics.TestSetFieldValues;
|
||||||
var PassException : boolean;
|
var PassException : boolean;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user