View Issue Details

IDProjectCategoryView StatusLast Update
0035830FPCLCLpublic2019-07-11 22:22
ReporterdevEric69Assigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSUbuntuOS Version18.04
Product VersionProduct Build 
Target VersionFixed in Version3.3.1 
Summary0035830: Request for clarification of messages concerning TField(s) errors.
DescriptionHello,

Sometimes, when you want to use a method like dataset.appendRecord([.../...]), you just get an error message saying "'data_1' is not a valid integer".
==> We do not know in which field we are trying to enter this bad value 'data_1'
==> if there are many fields in the table, the search can only be incremental, and last a long time.

So, there are error messages created by the fields that do not specify, neither the name of the field in question, nor its number in the "FieldDefs" (aka TFields collection in Lazarus), that the FieldDefs is dynamically created by Lazarus, or is created and then rendered persistent by the developer (by re-ordering them, as he wished).

==> I just went around the messages that are too sybillin, and I completed them to understand where to look. The additions are:
- the field name, which is a problem.
- the order of the field in its TFieldDefs. Indeed, if there is a problem in the order of the values sent via AppendRecord, it is that the position of the field is not where we think it is: indeed, some components descending from TDataset do not necessarily create a FieldDefs identical to the physical structure of the underlying table... to find the cause of the exception more quickly.
- a small homogenization of the display of the field name, always using DisplayLabel.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget3.2.0
Attached Files
  • patch_fields_messages.txt (3,912 bytes)
    In the file fields.inc:
    ~~~~~~~~~~~~~~~~~~~~~~~~
    
    .../...
    SNotAninteger            = '"%s" is not a valid integer : ';
    .../...
    
    
    
    
    ++  SFieldDescrInError            = 'Field "%s", with FieldNo %d (in its persistent or dynamic Dataset.Fields definition) has a problem'; 
    
    
    >> procedure TLongintField.SetAsString(const AValue: string);
    -- line_1538 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
    ++ line_1538 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TField.SetAsVariant(const AValue: variant);
    -- line_822  		on EVariantError do DatabaseErrorFmt(SFieldValueError, [DisplayName]);
    ++ line_822  		on EVariantError do DatabaseErrorFmt(SFieldDescrInError + SFieldValueError + ' (variant value)', [DisplayName, FFieldNo]); 
    
    
    >> procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean); 
    -- line_863		DatabaseErrorFmt(SNoDataset,[FieldName]);	
    ++ line_863		DatabaseErrorFmt(SNoDataset, [DisplayName]);
    
    
    >> class procedure TField.CheckTypeSize(AValue: Longint);
    -- line_950		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_950		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TNumericField.CheckTypeSize(AValue: Longint);
    -- line_1360		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_1360		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TNumericField.RangeError(AValue, Min, Max: Double);
    -- line_1366		DatabaseErrorFmt(SRangeError,[AValue,Min,Max,FieldName]);
    ++ line_1366		DatabaseErrorFmt(SRangeError, [AValue,Min,Max,DisplayName]);
    
    
    >> procedure TLongintField.SetAsString(const AValue: string); 
    -- line_1538		DatabaseErrorFmt(SNotAnInteger,[AValue]);
    ++ line_1538		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TLargeintField.SetAsString(const AValue: string);
    -- line_1693 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
    ++ line_1693 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TFloatField.SetAsString(const AValue: string);
    -- line_1928 		DatabaseErrorFmt(SNotAFloat, [AValue]);
    ++ line_1928 		DatabaseErrorFmt(SFieldDescrInError + SNotAFloat, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TBooleanField.SetAsString(const AValue: string);
    -- line_2046 		DatabaseErrorFmt(SNotABoolean,[AValue]);
    ++ line_2046 		DatabaseErrorFmt(SFieldDescrInError + SNotABoolean, [DisplayName, FFieldNo, AValue]);
    
    
    >> Procedure TBooleanField.SetDisplayValues(const AValue : String);
    -- line_2071       	DatabaseErrorFmt(SInvalidDisplayValues,[AValue]);
    ++ line_2071       	DatabaseErrorFmt(SFieldDescrInError + SInvalidDisplayValues, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TBinaryField.CheckTypeSize(AValue: Longint);
    -- line_2238		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_2238		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TBCDField.CheckTypeSize(AValue: Longint);
    -- line_2422		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_2422		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TFMTBCDField.CheckTypeSize(AValue: Longint);
    -- line_2593		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_2593		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TGuidField.CheckTypeSize(AValue: LongInt);
    -- line_3134		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_3134		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TFields.CheckfieldKind(Fieldkind: TFieldKind; Field: TField);
    -- line_3311		DatabaseErrorFmt(SInvalidFieldKind,[Field.FieldName]);
    ++ line_3311		DatabaseErrorFmt(SInvalidFieldKind, [Field.DisplayName]);;
    
    
    
    
  • patch_fields_messages-2.txt (3,911 bytes)
    In the file fields.inc:
    ~~~~~~~~~~~~~~~~~~~~~~~~
    
    .../...
    SNotAninteger            = '"%s" is not a valid integer : ';
    .../...
    
    
    
    
    ++  SFieldDescrInError            = 'Field "%s", with FieldNo %d (in its persistent or dynamic Dataset.Fields definition) has a problem'; 
    
    
    >> procedure TLongintField.SetAsString(const AValue: string);
    -- line_1538 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
    ++ line_1538 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TField.SetAsVariant(const AValue: variant);
    -- line_822  		on EVariantError do DatabaseErrorFmt(SFieldValueError, [DisplayName]);
    ++ line_822  		on EVariantError do DatabaseErrorFmt(SFieldDescrInError + SFieldValueError + ' (variant value)', [DisplayName, FFieldNo]); 
    
    
    >> procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean); 
    -- line_863		DatabaseErrorFmt(SNoDataset,[FieldName]);	
    ++ line_863		DatabaseErrorFmt(SNoDataset, [DisplayName]);
    
    
    >> class procedure TField.CheckTypeSize(AValue: Longint);
    -- line_950		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_950		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TNumericField.CheckTypeSize(AValue: Longint);
    -- line_1360		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_1360		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TNumericField.RangeError(AValue, Min, Max: Double);
    -- line_1366		DatabaseErrorFmt(SRangeError,[AValue,Min,Max,FieldName]);
    ++ line_1366		DatabaseErrorFmt(SRangeError, [AValue,Min,Max,DisplayName]);
    
    
    >> procedure TLongintField.SetAsString(const AValue: string); 
    -- line_1538		DatabaseErrorFmt(SNotAnInteger,[AValue]);
    ++ line_1538		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TLargeintField.SetAsString(const AValue: string);
    -- line_1693 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
    ++ line_1693 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TFloatField.SetAsString(const AValue: string);
    -- line_1928 		DatabaseErrorFmt(SNotAFloat, [AValue]);
    ++ line_1928 		DatabaseErrorFmt(SFieldDescrInError + SNotAFloat, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TBooleanField.SetAsString(const AValue: string);
    -- line_2046 		DatabaseErrorFmt(SNotABoolean,[AValue]);
    ++ line_2046 		DatabaseErrorFmt(SFieldDescrInError + SNotABoolean, [DisplayName, FFieldNo, AValue]);
    
    
    >> Procedure TBooleanField.SetDisplayValues(const AValue : String);
    -- line_2071       	DatabaseErrorFmt(SInvalidDisplayValues,[AValue]);
    ++ line_2071       	DatabaseErrorFmt(SFieldDescrInError + SInvalidDisplayValues, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TBinaryField.CheckTypeSize(AValue: Longint);
    -- line_2238		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_2238		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TBCDField.CheckTypeSize(AValue: Longint);
    -- line_2422		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_2422		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TFMTBCDField.CheckTypeSize(AValue: Longint);
    -- line_2593		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_2593		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> class procedure TGuidField.CheckTypeSize(AValue: LongInt);
    -- line_3134		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
    ++ line_3134		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);
    
    
    >> procedure TFields.CheckfieldKind(Fieldkind: TFieldKind; Field: TField);
    -- line_3311		DatabaseErrorFmt(SInvalidFieldKind,[Field.FieldName]);
    ++ line_3311		DatabaseErrorFmt(SInvalidFieldKind, [Field.DisplayName]);
    
    
    
    

Activities

devEric69

2019-07-11 19:19

reporter  

patch_fields_messages.txt (3,912 bytes)
In the file fields.inc:
~~~~~~~~~~~~~~~~~~~~~~~~

.../...
SNotAninteger            = '"%s" is not a valid integer : ';
.../...




++  SFieldDescrInError            = 'Field "%s", with FieldNo %d (in its persistent or dynamic Dataset.Fields definition) has a problem'; 


>> procedure TLongintField.SetAsString(const AValue: string);
-- line_1538 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
++ line_1538 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);


>> procedure TField.SetAsVariant(const AValue: variant);
-- line_822  		on EVariantError do DatabaseErrorFmt(SFieldValueError, [DisplayName]);
++ line_822  		on EVariantError do DatabaseErrorFmt(SFieldDescrInError + SFieldValueError + ' (variant value)', [DisplayName, FFieldNo]); 


>> procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean); 
-- line_863		DatabaseErrorFmt(SNoDataset,[FieldName]);	
++ line_863		DatabaseErrorFmt(SNoDataset, [DisplayName]);


>> class procedure TField.CheckTypeSize(AValue: Longint);
-- line_950		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_950		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TNumericField.CheckTypeSize(AValue: Longint);
-- line_1360		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_1360		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> procedure TNumericField.RangeError(AValue, Min, Max: Double);
-- line_1366		DatabaseErrorFmt(SRangeError,[AValue,Min,Max,FieldName]);
++ line_1366		DatabaseErrorFmt(SRangeError, [AValue,Min,Max,DisplayName]);


>> procedure TLongintField.SetAsString(const AValue: string); 
-- line_1538		DatabaseErrorFmt(SNotAnInteger,[AValue]);
++ line_1538		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);


>> procedure TLargeintField.SetAsString(const AValue: string);
-- line_1693 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
++ line_1693 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);


>> procedure TFloatField.SetAsString(const AValue: string);
-- line_1928 		DatabaseErrorFmt(SNotAFloat, [AValue]);
++ line_1928 		DatabaseErrorFmt(SFieldDescrInError + SNotAFloat, [DisplayName, FFieldNo, AValue]);


>> procedure TBooleanField.SetAsString(const AValue: string);
-- line_2046 		DatabaseErrorFmt(SNotABoolean,[AValue]);
++ line_2046 		DatabaseErrorFmt(SFieldDescrInError + SNotABoolean, [DisplayName, FFieldNo, AValue]);


>> Procedure TBooleanField.SetDisplayValues(const AValue : String);
-- line_2071       	DatabaseErrorFmt(SInvalidDisplayValues,[AValue]);
++ line_2071       	DatabaseErrorFmt(SFieldDescrInError + SInvalidDisplayValues, [DisplayName, FFieldNo, AValue]);


>> class procedure TBinaryField.CheckTypeSize(AValue: Longint);
-- line_2238		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_2238		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TBCDField.CheckTypeSize(AValue: Longint);
-- line_2422		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_2422		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TFMTBCDField.CheckTypeSize(AValue: Longint);
-- line_2593		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_2593		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TGuidField.CheckTypeSize(AValue: LongInt);
-- line_3134		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_3134		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> procedure TFields.CheckfieldKind(Fieldkind: TFieldKind; Field: TField);
-- line_3311		DatabaseErrorFmt(SInvalidFieldKind,[Field.FieldName]);
++ line_3311		DatabaseErrorFmt(SInvalidFieldKind, [Field.DisplayName]);;



devEric69

2019-07-11 19:22

reporter   ~0117186

Here is the uploaded message patch proposal, created manually...

patch_fields_messages-2.txt (3,911 bytes)
In the file fields.inc:
~~~~~~~~~~~~~~~~~~~~~~~~

.../...
SNotAninteger            = '"%s" is not a valid integer : ';
.../...




++  SFieldDescrInError            = 'Field "%s", with FieldNo %d (in its persistent or dynamic Dataset.Fields definition) has a problem'; 


>> procedure TLongintField.SetAsString(const AValue: string);
-- line_1538 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
++ line_1538 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);


>> procedure TField.SetAsVariant(const AValue: variant);
-- line_822  		on EVariantError do DatabaseErrorFmt(SFieldValueError, [DisplayName]);
++ line_822  		on EVariantError do DatabaseErrorFmt(SFieldDescrInError + SFieldValueError + ' (variant value)', [DisplayName, FFieldNo]); 


>> procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean); 
-- line_863		DatabaseErrorFmt(SNoDataset,[FieldName]);	
++ line_863		DatabaseErrorFmt(SNoDataset, [DisplayName]);


>> class procedure TField.CheckTypeSize(AValue: Longint);
-- line_950		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_950		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TNumericField.CheckTypeSize(AValue: Longint);
-- line_1360		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_1360		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> procedure TNumericField.RangeError(AValue, Min, Max: Double);
-- line_1366		DatabaseErrorFmt(SRangeError,[AValue,Min,Max,FieldName]);
++ line_1366		DatabaseErrorFmt(SRangeError, [AValue,Min,Max,DisplayName]);


>> procedure TLongintField.SetAsString(const AValue: string); 
-- line_1538		DatabaseErrorFmt(SNotAnInteger,[AValue]);
++ line_1538		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);


>> procedure TLargeintField.SetAsString(const AValue: string);
-- line_1693 		DatabaseErrorFmt(SNotAnInteger,[AValue]);
++ line_1693 		DatabaseErrorFmt(SFieldDescrInError + SNotAnInteger, [DisplayName, FFieldNo, AValue]);


>> procedure TFloatField.SetAsString(const AValue: string);
-- line_1928 		DatabaseErrorFmt(SNotAFloat, [AValue]);
++ line_1928 		DatabaseErrorFmt(SFieldDescrInError + SNotAFloat, [DisplayName, FFieldNo, AValue]);


>> procedure TBooleanField.SetAsString(const AValue: string);
-- line_2046 		DatabaseErrorFmt(SNotABoolean,[AValue]);
++ line_2046 		DatabaseErrorFmt(SFieldDescrInError + SNotABoolean, [DisplayName, FFieldNo, AValue]);


>> Procedure TBooleanField.SetDisplayValues(const AValue : String);
-- line_2071       	DatabaseErrorFmt(SInvalidDisplayValues,[AValue]);
++ line_2071       	DatabaseErrorFmt(SFieldDescrInError + SInvalidDisplayValues, [DisplayName, FFieldNo, AValue]);


>> class procedure TBinaryField.CheckTypeSize(AValue: Longint);
-- line_2238		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_2238		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TBCDField.CheckTypeSize(AValue: Longint);
-- line_2422		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_2422		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TFMTBCDField.CheckTypeSize(AValue: Longint);
-- line_2593		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_2593		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> class procedure TGuidField.CheckTypeSize(AValue: LongInt);
-- line_3134		DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
++ line_3134		DatabaseErrorFmt(SFieldDescrInError + SInvalidFieldSize, [DisplayName, FFieldNo, AValue]);


>> procedure TFields.CheckfieldKind(Fieldkind: TFieldKind; Field: TField);
-- line_3311		DatabaseErrorFmt(SInvalidFieldKind,[Field.FieldName]);
++ line_3311		DatabaseErrorFmt(SInvalidFieldKind, [Field.DisplayName]);



Michael Van Canneyt

2019-07-11 22:22

administrator   ~0117189

There are some problems with your patch.
* In class methods (CheckTypeSize) the displayName is not available, since this is a class method.
  So you did not compile your patch.
* The error message is shown to the user.
   The user will only be confused by the field number, so I removed the field number.
The display name of the field should be enough to identify the field.
I applied what could be applied of your patch.

Issue History

Date Modified Username Field Change
2019-07-11 19:11 devEric69 New Issue
2019-07-11 19:19 devEric69 File Added: patch_fields_messages.txt
2019-07-11 19:22 devEric69 File Added: patch_fields_messages-2.txt
2019-07-11 19:22 devEric69 Note Added: 0117186
2019-07-11 22:17 Michael Van Canneyt Project Patches => FPC
2019-07-11 22:22 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-07-11 22:22 Michael Van Canneyt Status new => resolved
2019-07-11 22:22 Michael Van Canneyt Resolution open => fixed
2019-07-11 22:22 Michael Van Canneyt Fixed in Version => 3.3.1
2019-07-11 22:22 Michael Van Canneyt FPCTarget => 3.2.0
2019-07-11 22:22 Michael Van Canneyt Note Added: 0117189