cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Recursive CDS data type

former_member748892
Discoverer
0 Likes
2,533

Dear colleagues,

I'm trying to create a recursive data type using SAP CDS version 5.0.6. So far I experimented with the following:

type Node { value: String; children: many Node; }

This yields an error: 'Illegal circular reference'. Do you know how can this use case modelled in CDS?

Thanks,

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
SAP Mentor
SAP Mentor

Have you tried to follow the example in:

schema.cds#L27

former_member748892
Discoverer
0 Likes

It did the trick, thanks!

Answers (1)

Answers (1)

Recursive type are indeed not supported in CDS. Before we would invest in this direction, we would have to check whether they would be supported in consumers of CDS models.

In SQL, it would be fine in combination with MANY (like your example), because then it would be mapped to a CLOB... In OData and OData consumers...

In CDS, you have recursive data structures via Associations/compositions

entity Node {
  key id: UUID;
  value: String;
  children: Composition of Node;
}

Regards,
Christoph