AQL type predicate

Our EHR Server end-user consultants report that sometimes filtering by object type would be useful in AQL. As an example they point out laboratory results where archetypes and templates allow for many data-value types at the leaf level, and sometimes a query might want to only include DV_QUANTITYs and DV_SCALEs. They propose a solution in a sense of adding an implicit attribute @class which could be used like this: myResult/@class MATCHES {"DV_QUANTITY","DV_SCALE"}.

I must say I prefer a solution that was mentioned in passing in the Safety features in AQL: subject topic, which is a function that would also take inheritance into account: is_type(myResult, "DV_QUANTITY") OR is_type(myResult, "DV_SCALE").

We have a habit of “move fast and break standardisation” due to market forces, so at this point I’m not pushing for any de-iure solution; I’d just like to check with other implementors, particularly @bna, if anyone already has such a functionality and what their syntax is; and if nobody has this, what syntax do others prefer.

I generally prefer functions over language construct, so better is_type().

I hate to complicate this discussion but there possibly is a reverse use-case around ‘casting’ when commiting data (or in expressions) particularly with stringified / falt data formats. e.g. where there is a choice of datatypes that can be committed how can we make sure the correct datatype is populated - I guess this is ‘casting’ - Better’s flat format supports this but a litlle clunky IMO (sorry @Matija!1).

I guess just to bear in mind that there are 2 sides to the issue of datatype choices - might be good to be coherent in our approach.

BTW, we had this in the spec already, but it is in process of being removed, because no-one implemented it:

We must re-discuss whether to use that syntax or any other.