0 Replies
      Latest reply on Jun 29, 2019 1:31 AM by peteog
      peteog Level 1 Level 1 (0 points)

        Is it possible to create a derived attribute with a subquery?

         

        Given two entities Feed and Item, where a Feed has many items, and an Item has an isRead attribute. I'd like to be able to specify a Derivation attribute on Feed with the following expression:

         

        SUBQUERY(items, $item, $item.isRead != 1).@count

         

        i.e. the number of unread items.

         

        When I use this expression and run this I get an error:

         

        Unable to generate optimized model (sql model generation failed Error Domain=NSCocoaErrorDomain Code=134097 "(null)" UserInfo={NSUnderlyingException=Invalid keypaths found in derived attribute (unsupported function)})