mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 22:09:45 +02:00
* Displayvalues can omit false part. Fix issue #39371
This commit is contained in:
parent
bde7b73a3e
commit
d9996607b8
packages/fcl-db
@ -2669,11 +2669,13 @@ Procedure TBooleanField.SetDisplayValues(const AValue : String);
|
||||
var I : longint;
|
||||
|
||||
begin
|
||||
if aValue='' then
|
||||
DatabaseErrorFmt(SFieldError+SInvalidDisplayValues,[DisplayName,AValue]);
|
||||
If FDisplayValues<>AValue then
|
||||
begin
|
||||
I:=Pos(';',AValue);
|
||||
If (I<2) or (I=Length(AValue)) then
|
||||
DatabaseErrorFmt(SFieldError+SInvalidDisplayValues,[DisplayName,AValue]);
|
||||
If I=0 then
|
||||
I:=Length(aValue)+1;
|
||||
FdisplayValues:=AValue;
|
||||
// Store display values and their uppercase equivalents;
|
||||
FDisplays[False,True]:=Copy(AValue,1,I-1);
|
||||
|
@ -35,6 +35,7 @@ type
|
||||
procedure TestSupportWordFields;
|
||||
procedure TestSupportStringFields;
|
||||
procedure TestSupportBooleanFields;
|
||||
procedure TestSupportBooleanFieldDisplayValue;
|
||||
procedure TestSupportFloatFields;
|
||||
procedure TestSupportLargeIntFields;
|
||||
procedure TestSupportDateFields;
|
||||
@ -2716,6 +2717,22 @@ begin
|
||||
ds.Close;
|
||||
end;
|
||||
|
||||
procedure TTestDBBasics.TestSupportBooleanFieldDisplayValue;
|
||||
var i : byte;
|
||||
ds : TDataset;
|
||||
Fld : TField;
|
||||
BoolFld : TBooleanField absolute Fld;
|
||||
begin
|
||||
TestFieldDefinition(ftBoolean,2,ds,Fld);
|
||||
CheckEquals(TBooleanField,Fld.ClassType,'Correct class');
|
||||
BoolFld.DisplayValues:='+';
|
||||
ds.Edit;
|
||||
Fld.AsBoolean:=True;
|
||||
CheckEquals('+',Fld.DisplayText,'Correct true');
|
||||
Fld.AsBoolean:=False;
|
||||
CheckEquals('',Fld.DisplayText,'Correct false');
|
||||
end;
|
||||
|
||||
procedure TTestDBBasics.TestSupportFloatFields;
|
||||
|
||||
var i : byte;
|
||||
|
Loading…
Reference in New Issue
Block a user