Rohit_Nz
(Gupta Rohit)
February 14, 2025, 4:07am
1
I see many of the fields have this tagged in the Entities for XData, on the server. But not all.
I can see why any fields that are part of an index may have them. But its on too many unexpected fields. It is even on fields it should not be on. Such as
Ref (Id) which is an autoincrement field and should not be populated.
Created and Modified which are automatically populated by the database (because of their definitions).
I know I can remove the tag. I was just wondering about the logic behind it, in case I should consider that in my decision.
Example
[Entity]
[Table('registrations')]
[Id('FRef', TIdGenerator.IdentityOrSequence)]
Tregistrations = class
private
[Column('Ref', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FRef: Int64;
[Column('Reg_Type', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FReg_Type: String;
[Column('Platform', [TColumnProp.Required], 40)]
FPlatform: string;
[Column('Browser', [TColumnProp.Required], 40)]
FBrowser: string;
[Column('Email', [TColumnProp.Required], 80)]
FEmail: string;
[Column('Device_Name', [TColumnProp.Required], 80)]
FDevice_Name: string;
[Column('Fingerprint', [], 80)]
FFingerprint: Nullable<string>;
[Column('Created', [TColumnProp.Required])]
FCreated: TDateTime;
[Column('Modified', [TColumnProp.Required])]
FModified: TDateTime;
[Column('Created_By', [TColumnProp.Required])]
FCreated_By: Int64;
[Column('Modified_By', [TColumnProp.Required])]
FModified_By: Int64;
wlandgraf
(Wagner Landgraf)
February 14, 2025, 12:14pm
2
Those are Aurelius mapping attributes, which is how the class is mapped to the database. It's database information.
Hence, TColumnProp.Required
means the field will be required in database - i.e., NOT NULL.
Rohit_Nz
(Gupta Rohit)
February 15, 2025, 1:36pm
3
In some cases there are default values, so I don't need the user hassled that they have not entered a value.
I am also puzzled by NoInsert , NoUpdate .
[Entity]
[Table('bookings')]
[Id('FRef', TIdGenerator.IdentityOrSequence)]
Tbookings = class
private
[Column('Ref', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FRef: Int64;
[Column('Status', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
FStatus: string;
[Column('Client_Ref', [TColumnProp.Required])]
FClient_Ref: Int64;
These are appropriate for the Ref
field as its Autoincrement
. Even then, I find it useful during maintenance to be able to change the Ref
number.
But they are not appropriate for the Status
field
wlandgraf
(Wagner Landgraf)
February 17, 2025, 2:48pm
4
Again, this is not user related. This is database information indicating the database field is NOT NULL.
This is by default for generated identity fields. You can always change it, either manually or automatically using Data Modeler scripts, examples:
You can import it using TMS Data Modeler and remove the TColumnProp.Required from the list of column properties using customization script . For example:
procedure OnColumnGenerated(Args: TColumnGeneratedArgs);
begin
if Args.DBField.FieldName = 'Dummy' then
begin
TCodeSnippetExpression(Args.ColumnAttr.Arguments[1].Value).Value := '[TColumnProp.NoInsert, TColumnProp.NoUpdate]';
end;
end;
You can do that via customization scripts . Example:
procedure OnColumnGenerated(Args: TColumnGeneratedArgs);
begin
if Args.DBField.FieldName = 'CreationDate' then
begin
TCodeSnippetExpression(Args.ColumnAttr.Arguments[1].Value).Value := '[TColumnProp.NoUpdate]';
end;
end;
If you want different DTOs (classes) for different endpoints, then in this case you need to effectively create different DTO classes for each endpoint.