The final OData query bits, yes we're nearly there
So yes, we are nearly there, in fact we only have a few query options remaining, which I'll cover entirely here because they're all pretty miniscule.
- Learning OMeta through JSON
- Introduction to the OData Parser
- First steps in writing the OData Parser
- Nested resource paths in OData
- Service operations in OData
- Query options in OData
- Paging support in OData
- Filtering support in OData
- Recursive query support in OData
- 'Not' support for OData
- Arithmetic operator support in OData
- Precedence grouping in OData
- Filter query methods in OData
Expand
Expand allows the expansion of a particular property path in OData, like so
Expand the path Products/Suppliers
/Categories?$expand=Products/SuppliersExpand the path Suppliers AND expand the path Products
/Categories?$expand=Suppliers,ProductsSo this is quite easy, $expand expects a list of ResourcePath, separated by a comma.
I'll not show the tests for this, you can assume I have some though, with the appropriate data appearing on the model..
ExpandOption =
seq("$expand=")
listOf(`PropertyPath, ','):properties -> { name: "$expand", value: { properties: properties }}
,Doesn't take a genius to work that one out does it :)
Format
This one is a doozy, the docs pretty much say it accepts
- application/atom+xml
- application/xml
- application/json
- Any other valid IANA content type
So what we're saying here is that we'll parse any content type, what I'll do is just parse the general pattern to make sure it doesn't contain garbage and leave it at that.
FormatOption =
seq("$format=")
ContentType:type -> { name: "$format", value: type }
,
ContentType =
< letter+
'/'
letter+
(
'+' letter+
)?
>There are probably more rules than that but it's easily improved later
Select
Select tells us what is going to be brought back from a query, this can either be a property path, a collection of property paths or an asterisk.
An asterisk means bring back EVERYTHING. Nothing special.
SelectOption =
seq("$select=")
(
"*" -> '*'
| listOf(`PropertyPath, ','):properties -> { properties: properties }
):value -> { name: "$select", value: value }
,Highlighting a problem or three
That's pretty much the entire spec sorted out, and we have a few tidy ups on our hand
- The model we're building isn't meaningful enough
- I've done some messy OMeta, it needs tidying
- I'm not handling primitive types properly (ResourceNames, ResourceComponents, Numbers etc)
I'll sort all these out in the next entry (I imagine that there will have been some comments made about these already in the future... in the past now, I wrote all this a month ago after all) and then we'll be finished and onto something new.