The final OData query bits, yes we're nearly there

Published on 2013-4-22

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.


Expand allows the expansion of a particular property path in OData, like so

Expand the path Products/Suppliers


Expand the path Suppliers AND expand the path Products


So 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 = 
  listOf(`PropertyPath, ','):properties -> { name: "$expand", value: { properties: properties }}

Doesn't take a genius to work that one out does it :)


This one is a doozy, the docs pretty much say it accepts

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 = 
  ContentType:type -> { name: "$format", value: type }

ContentType = 
  < letter+
      '+' letter+

There are probably more rules than that but it's easily improved later


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 =
    "*"                                 -> '*' 
  | 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

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.

2020 © Rob Ashton. ALL Rights Reserved.