If a query entity returns an empty set (due to the filters), will that empty set

Certified Senior Developer
If a query entity returns an empty set (due to the filters), will that empty set be automatically cast to the type of the Data Entity, or do we need to perform this cast in our rules to ensure the query entity is null-safe (it always returns the expected type, whether it is an empty array or not. Otherwise using dot-notation to access fields of a CDT will result in errors, although the property() function would also let us be null-safe)....

OriginalPostID-131791

OriginalPostID-131791

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    Hi pavithrac,

    I did mention the property() function in the original post (which is the same as the index() function). However, I was seeking suggestions where it wouldn't be necessary to wrap every access to a CDT field with property/index. Checking if the query entity returns an empty set, and returning a cast of {} to the CDT type seems to do the trick.
Reply
  • 0
    Certified Senior Developer
    Hi pavithrac,

    I did mention the property() function in the original post (which is the same as the index() function). However, I was seeking suggestions where it wouldn't be necessary to wrap every access to a CDT field with property/index. Checking if the query entity returns an empty set, and returning a cast of {} to the CDT type seems to do the trick.
Children
No Data