Nullable property of structured type


(Alexander Pustotin) #1


In my RODL I have a structured type that, in turn, contains several structured properties. Some of these properties can be set to nil. However, the code generator creates similar getters for all properties which give no chance to implement what I would like.

I know that the struct type definition in a rodl file has AutoCreateParams attribute that is set to “1” by default. I could manually change this to AutoCreateParams="0" but it means that again all getters will change.


  1. How can I implement a sort of AutoCreateParams attribute at the property level?
  2. Do you plan to implement working with AutoCreateParams in the ServiceBuilder UI? Manually editing a rodl file with a text editor doesn’t look too robust.

best regards

(EvgenyK) #2


You can easily implement this in Code-First server.

(Alexander Pustotin) #3


and what is the best practice for such a case? I would prefer not touch auto-generated _RODLTypes unit.

(EvgenyK) #4

it can be like:

  NewStruct = class(TROComplexType)
    property NullableProp: NewStruct1 read fNullableProp write fNullableProp;
    property NotNullableProp: NewStruct2 read GetNotNullableProp write fNotNullableProp;

function NewStruct.GetNotNullableProp: NewStruct2;
  if not assigned(fNotNullableProp) then begin
    fNotNullableProp := NewStruct2.Create();
  result := fNotNullableProp;

(Alexander Pustotin) #5

does it mean that I have to manually edit generated file?

(EvgenyK) #6

this contains initial conversion of RODL.
it wasn’t regenerated automatically so feel free to update it.

yes, you can update it as you want.
also you may need to update Assign method - it can create nullable structs in default implementation.

(Alexander Pustotin) #7

thank you for the fast replies.