You've already forked lazarus-ccr
RxFPC:TZeosDataSetSortEngine fix sorting on collimns with space in field's name
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4595 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -52,17 +52,21 @@ type
|
|||||||
implementation
|
implementation
|
||||||
uses ZDbcIntfs, ZVariant;
|
uses ZDbcIntfs, ZVariant;
|
||||||
|
|
||||||
|
function FixFieldName(S:string):string;inline;
|
||||||
|
begin
|
||||||
|
if Pos(' ', S)>0 then
|
||||||
|
S:='"'+S+'"';
|
||||||
|
Result:=S;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TZeosDataSetSortEngine.Sort(FieldName: string; ADataSet: TDataSet;
|
procedure TZeosDataSetSortEngine.Sort(FieldName: string; ADataSet: TDataSet;
|
||||||
Asc: boolean; SortOptions: TRxSortEngineOptions);
|
Asc: boolean; SortOptions: TRxSortEngineOptions);
|
||||||
begin
|
begin
|
||||||
if not Assigned(ADataSet) then exit;
|
if not Assigned(ADataSet) then exit;
|
||||||
|
|
||||||
if Pos(' ', FieldName)>0 then
|
|
||||||
FieldName:='"'+FieldName+'"';
|
|
||||||
|
|
||||||
if ADataSet is TZAbstractRODataset then
|
if ADataSet is TZAbstractRODataset then
|
||||||
begin
|
begin
|
||||||
TZAbstractRODataset(ADataSet).SortedFields:=FieldName;
|
TZAbstractRODataset(ADataSet).SortedFields:=FixFieldName(FieldName);
|
||||||
if Asc then
|
if Asc then
|
||||||
TZAbstractRODataset(ADataSet).SortType:=stAscending
|
TZAbstractRODataset(ADataSet).SortType:=stAscending
|
||||||
else
|
else
|
||||||
@ -84,7 +88,7 @@ begin
|
|||||||
while C>0 do
|
while C>0 do
|
||||||
begin
|
begin
|
||||||
if S<>'' then S:=S+';';
|
if S<>'' then S:=S+';';
|
||||||
S:=S + Copy(ListField, 1, C-1);
|
S:=S + FixFieldName(Copy(ListField, 1, C-1));
|
||||||
Delete(ListField, 1, C);
|
Delete(ListField, 1, C);
|
||||||
|
|
||||||
if (i<=High(Asc)) and (not Asc[i]) then
|
if (i<=High(Asc)) and (not Asc[i]) then
|
||||||
@ -96,7 +100,7 @@ begin
|
|||||||
if ListField<>'' then
|
if ListField<>'' then
|
||||||
begin
|
begin
|
||||||
if S<>'' then S:=S+';';
|
if S<>'' then S:=S+';';
|
||||||
S:=S + ListField;
|
S:=S + FixFieldName(ListField);
|
||||||
if (i<=High(Asc)) and (not Asc[i]) then
|
if (i<=High(Asc)) and (not Asc[i]) then
|
||||||
S:=S + ' DESC';
|
S:=S + ' DESC';
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user