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:
alexs75
2016-03-25 08:19:10 +00:00
parent 243fa395dd
commit df2afa4a3a

View File

@ -52,17 +52,21 @@ type
implementation
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;
Asc: boolean; SortOptions: TRxSortEngineOptions);
begin
if not Assigned(ADataSet) then exit;
if Pos(' ', FieldName)>0 then
FieldName:='"'+FieldName+'"';
if ADataSet is TZAbstractRODataset then
begin
TZAbstractRODataset(ADataSet).SortedFields:=FieldName;
TZAbstractRODataset(ADataSet).SortedFields:=FixFieldName(FieldName);
if Asc then
TZAbstractRODataset(ADataSet).SortType:=stAscending
else
@ -84,7 +88,7 @@ begin
while C>0 do
begin
if S<>'' then S:=S+';';
S:=S + Copy(ListField, 1, C-1);
S:=S + FixFieldName(Copy(ListField, 1, C-1));
Delete(ListField, 1, C);
if (i<=High(Asc)) and (not Asc[i]) then
@ -96,7 +100,7 @@ begin
if ListField<>'' then
begin
if S<>'' then S:=S+';';
S:=S + ListField;
S:=S + FixFieldName(ListField);
if (i<=High(Asc)) and (not Asc[i]) then
S:=S + ' DESC';
end;