ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/ibcontrols/IBLookupComboEditBox.pas
(Generate patch)

Comparing:
ibx/trunk/ibcontrols/IBLookupComboEditBox.pas (file contents), Revision 278 by tony, Mon Feb 4 13:47:40 2019 UTC vs.
ibx/branches/journaling/ibcontrols/IBLookupComboEditBox.pas (file contents), Revision 362 by tony, Tue Dec 7 13:27:39 2021 UTC

# Line 113 | Line 113 | type
113      procedure UpdateSQL(Sender: TObject; Parser: TSelectSQLParser);
114      procedure HandleEnter(Data: PtrInt);
115      procedure UpdateLinkData(Sender: TObject);
116 +    procedure ValidateListField;
117    protected
118      { Protected declarations }
119      procedure ActiveChanged(Sender: TObject);
# Line 159 | Line 160 | type
160  
161   implementation
162  
163 < uses Variants, LCLProc, LazUTF8, IBUtils;
163 > uses Variants, LCLProc, LazUTF8, IBUtils, IBMessages;
164  
165   { TIBLookupControlLink }
166  
# Line 251 | Line 252 | begin
252       and ListSource.DataSet.Active   then
253    begin
254      begin
255 +      ValidateListField;
256        if varIsNull(FLastKeyValue) and (ItemIndex = -1) then
257          KeyValue := ListSource.DataSet.FieldByName(KeyField).AsVariant
258        else
# Line 368 | Line 370 | begin
370                   UTF8Insert(sPrefixText, sResultText, 1);
371                 end;
372                 Text := sResultText;
371               SelStart := iSelStart;
372               SelLength := UTF8Length(Text) - iSelStart;
373               end;
374 +             SelStart := iSelStart;
375 +             SelLength := UTF8Length(Text) - iSelStart;
376             end
377             else
378             begin
# Line 389 | Line 391 | procedure TIBLookupComboEditBox.UpdateSQ
391    Parser: TSelectSQLParser);
392   var FieldPosition: integer;
393      FilterText: string;
394 +    SQLDialect: integer;
395   begin
396    if FFiltered then
397    begin
# Line 396 | Line 399 | begin
399        FilterText := FCurText
400      else
401        FilterText := Text;
402 +
403 +    if Parser.DataSet <> nil then
404 +      SQLDialect := (Parser.DataSet as TIBCustomDataSet).Database.SQLDialect
405 +    else
406 +      SQLDialect := 1;
407 +
408      if cbactSearchCaseSensitive in AutoCompleteText then
409 <      Parser.Add2WhereClause(GetRelationNameQualifier + '"' + ListField + '" Like ''' +
409 >      Parser.Add2WhereClause(GetRelationNameQualifier + QuoteIdentifierIfNeeded(SQLDialect,ListField) + ' Like ''' +
410                                    SQLSafeString(FilterText) + '%''')
411      else
412 <      Parser.Add2WhereClause('Upper(' + GetRelationNameQualifier + '"' +  ListField + '") Like Upper(''' +
412 >      Parser.Add2WhereClause('Upper(' + GetRelationNameQualifier + QuoteIdentifierIfNeeded(SQLDialect,ListField) + ') Like Upper(''' +
413                                    SQLSafeString(FilterText) + '%'')');
414  
415      if cbactSearchAscending in AutoCompleteText then
# Line 425 | Line 434 | begin
434      ListSource.DataSet.FieldByName(ListField).AsString := Text
435   end;
436  
437 + {Check to ensure that ListField exists and convert to upper case if necessary}
438 +
439 + procedure TIBLookupComboEditBox.ValidateListField;
440 + var SQLDialect: integer;
441 +    FieldNames: TStringList;
442 + begin
443 +  if (ListSource = nil) or (ListSource.DataSet = nil) or
444 +    not (ListSource.DataSet is TIBCustomDataSet) or
445 +     ((ListSource.DataSet as TIBCustomDataSet).Database = nil) then Exit;
446 +  SQLDialect := (ListSource.DataSet as TIBCustomDataSet).Database.SQLDialect;
447 +  FieldNames := TStringList.Create;
448 +  try
449 +    FieldNames.CaseSensitive := true;
450 +    FieldNames.Sorted := true;
451 +    FieldNames.Duplicates := dupError;
452 +    ListSource.DataSet.GetFieldNames(FieldNames);
453 +    if FieldNames.IndexOf(ListField) = -1 then {not found}
454 +    begin
455 +      if (SQLDialect = 3) and (FieldNames.IndexOf(AnsiUpperCase(ListField)) <> - 1) then {normalise to upper case}
456 +        ListField := AnsiUpperCase(ListField)
457 +      else
458 +        IBError(ibxeListFieldNotFound,[ListField])
459 +    end;
460 +  finally
461 +    FieldNames.Free;
462 +  end;
463 + end;
464 +
465   procedure TIBLookupComboEditBox.CheckAndInsert;
466   var Accept: boolean;
467      NewKeyValue: variant;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines