TMS Datamodeller creating read-only properties for CITEXT fields (PostgreSQL)

I have created a postgres database with numerous columns defined as datatype CITEXT. When using TMSDataModeller to create Aurelius classes from the database it is defining these columns as class fields of type variant, and the associated properties are being defined readonly. Even if I map the fields to be (say) widestring or nullable(widestring) the properties are created read only. Columns with native types like bigint or timestamp are created with properties that are both readable and writeable

Hi @Burgess_John, welcome to TMS Support Center.

Data Modeler is not aware of such type, thus it creates the properties that way.

Easiest way to work around this is to use a customization script to modify all such properties on the fly, add a setter and change the type to the value you want.

These topics in Support Center show examples for a similar case:

Hi Wagner

Thank you for your assistance. I have attempted to create a script to deal with this problem but it does not seem to be able to identify datatype of citext.

I applied the following script in the

procedure OnColumnGenerated(Args: TColumnGeneratedArgs);
begin
  if Args.DBField.DataTypeName = 'citext' then 
  begin        
    if Args.DBField.Required then
    begin           
      Args.Field.FieldType.BaseType := 'string';
      Args.Prop.PropertyType.BaseType := 'string';      
      Args.Prop.HasSetter := true;
    end else
    begin
      Args.Field.FieldType.BaseType := 'Nullable<string>';
      Args.Prop.PropertyType.BaseType := 'Nullable<string>'; 
      Args.Prop.HasSetter := true;
    end;
  end;   
  Args.Field.Name := 'Jolt' + Args.Field.Name; //added just to check the script is invoked
end;

I added the line at the bottom (prepending "Jolt" to my field names) just to check that the script is actually applied, and it is.

But the citext fields are still being declared as type variant, and no setter is created. It would seem that the outer if statement (Args.DBField.DataTypeName = 'citext' then) is never being evaluated as true.

I assume that it's not necessary to separately map the Delphi field types given that this script should do that.

Can you send a screenshot of the window where you edit the field definition in Data Modeler? Probably the data type is not citext, and such information is elsewhere.

Maybe you can check also the DBField.Expression property. Finally, don't forget strings are case sensitive, so if DataTypeName is CITEXT it won't work.

You can use LowerCase to force the string to lower case before comparing to citext.