Repository navigation
What's new
$select goes into a complex value
Selecting a field of a complex property was a 400 that gave the wrong advice, as if Location were a navigation:
GET /odata/v4/TripPin/Airports?$select=IcaoCode,Location/City/Name
{"error":{"code":"BadRequest","message":"$select can't go through Location: for a navigation, write $expand=Location($select=City/Name)"}}
V4 now serves it, with only the fields the path names, and the context URL lists the path:
{
"@odata.context": "/odata/v4/TripPin/$metadata#Airports(IcaoCode,Location/City/Name)",
"value": [{ "IcaoCode": "1", "Location": { "City": { "Name": "Paris" } } }]
}- At any depth (
Place/Addr/City), and in each item of a collection (AddressInfo/City). Several paths into one value are merged. - On a collection, a single entity, inside
$expand(...;$select=...), and with an$applywhose rows are still entities:identity,filter,orderby,concat. - A complex value selected whole as well (
$select=Addr,Addr/City) is whole. - A path that leads nowhere is a
400that says why:Nope is not a property of Addr,City isn't a complex property, so a path can't go into it. A path through a navigation still says to write$expand=Nav($select=...). A type cast in the path (Place/NS.Place2/Addr) is a501. - V2 has no such path:
$select=Addr/Citystays a400there. SelectAddr.
A generated row's names and emails belong to one person
A generated person had someone else's email addresses:
{ "FirstName": "Hugo", "LastName": "Silva", "Emails": ["grace.garcia@example.com", "david.schmidt@example.com"] }A row now has one person, and its first and last name, contact name (ContactName, ContactPerson) and email addresses are theirs. A collection of addresses gets one per domain:
{ "FirstName": "Hugo", "LastName": "Silva", "Emails": ["hugo.silva@example.com", "hugo.silva@example.org"] }CreatedBy, ChangedBy, Owner and Manager still get someone else: the person who changed an order isn't its contact.
A plain Name is what its type says
A property called just Name was its type's name and a number, so a city in France was called City 1:
"City": { "CountryRegion": "France", "Name": "City 1", "Region": "Île-de-France" }It now follows the type it's in, and agrees with the rest of the row:
"City": { "CountryRegion": "France", "Name": "Paris", "Region": "Île-de-France" }- A
CityorTowngets the row's city, aCountryorRegionits country or region, aProductorMaterialthe row's product, aPerson,EmployeeorContactthe row's person, and aCompany,Supplier,Vendor,Customer,Partner,ManufacturerorShippera company's name. --explainno longer lists these as filler. ANameits type says nothing about, as anAirline's, is stillAirline 1, and--explainstill says so.
An entity without its key says which it is
With a $select that leaves out the key, nothing in the response said which entity a row was:
GET /odata/v4/PurchaseOrderSrv/PurchaseOrderSet?$select=Supplier
{"Supplier":"Hooli Electronics"}
That made a changed entity in a delta useless: {"Status":"Completed"}, but which order? Such an entity now carries its @odata.id, as OData 4.01 requires:
{ "@odata.id": "/odata/v4/PurchaseOrderSrv/PurchaseOrderSet('4500000001')", "Supplier": "Hooli Electronics" }The same goes for an entity in an $expand, in a delta and in an $apply result. UI5 always selects the key, so a UI5 app sees no change.
Context URLs list expanded navigations
An $expand without its own $select was left out of the context URL, or listed as empty while it expanded more:
$expand=Items → $metadata#PurchaseOrderSet
$select=FirstName&$expand=Friends($expand=Friends($select=UserName)) → $metadata#People(FirstName,Friends())
The select-list now has every expanded navigation, with what it selects or expands, or () when it does neither (OData 4.01 Part 1, 10.9 and 10.10):
$metadata#PurchaseOrderSet(Items())
$metadata#People(FirstName,Friends(Friends(UserName)))
Grouping by a complex path is a 501 that says so
$apply doesn't follow a path into a complex value, but it said the complex property wasn't a navigation:
GET /odata/v4/TripPin/Airports?$apply=groupby((Location/City/Region))
{"error":{"code":"BadRequest","message":"$apply: Location in Location/City/Region is not a navigation of Airport"}}
It's now a 501, like the other parts of $apply the server doesn't do:
{"error":{"code":"NotImplemented","message":"$apply: Location/City/Region goes into the complex property Location, which is not supported"}}
$filter and $orderby do follow it: $filter=Location/City/Region eq 'Zurich'.
Docs
- Supported OData features no longer says that
$filterand$orderbycan't go into a complex value. They can, since v0.24.0. - Its list of what's a
501is one list again.
Upgrading
- Generated rows change in every model, data files aside. Names, emails and a plain
Namechange as above, and other values in the same rows move too, as the generator draws its numbers in a different order. A test that expects a generated value needs the new one. - A V4 entity whose
$selectleaves out any of its key properties now has@odata.id. A test that compares such an entity whole needs it, or the key in its$select. - A V4 context URL with an
$expandnow has a select-list:PurchaseOrderSet(Items()), notPurchaseOrderSet. - V4's
$select=Addr/Cityis a200, not a400. $applygrouping or aggregating by a path into a complex value is a501, not a400.
Install
npx odata-prova@0.25.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.25.0Details
Query options and Aggregation in Supported OData features, Not supported, and Mock data.