Repository navigation
Releases
v0.25.0: $select into complex values
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.
v0.24.1: currency decimals
What's new
Generated amounts have their currency's decimals
A generated order in yen had cents, which the yen doesn't have:
{ "Material": "Safety Valve", "NetPrice": 254.87, "Currency": "JPY" }An amount now has the decimals of its currency: none in JPY, KRW or VND, three in KWD, BHD or OMR, two in the rest. The number is the one SAP shows for them, with its digits kept and the point moved, so a price in yen is a price in yen:
{ "Material": "Safety Valve", "NetPrice": 25487.00, "Currency": "JPY" }An order's total follows: 11468.21 JPY is now 1146821.00 JPY, the sum of its items' prices times their quantities.
- The currency of an amount is the property the metadata gives it (
sap:unit,Measures.ISOCurrency), or the row's only currency when the amount is named like one:NetPrice,TotalAmount,Cost. ScaleandPrecisionstill win. AScaleof 2 cuts a dinar's third decimal, and a number too long for thePrecisionkeeps its point and loses only the decimals.- An amount with a
Scaleof 3 in a two-decimal currency ends in0:12.340 EUR, not12.345 EUR. - An amount a mock rule sets keeps the rule's value. Quantities, keys and the rows of data files aren't touched.
The PurchaseOrderSrv example says which currency an amount is in
Its metadata.xml had amounts and a currency with nothing joining them, so a Fiori app generated from it showed 1146821.00 in one column and JPY in another. The amounts and the quantity now name their currency and unit, as an SAP Gateway service does:
<Property Name="Currency" Type="Edm.String" Nullable="false" MaxLength="3" sap:semantics="currency-code"/>
<Property Name="TotalAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="2" sap:unit="Currency"/>The generated V4 $metadata carries the same as Measures.ISOCurrency and Measures.Unit. The example's rows are the same as before.
Docs
- Keeping the data says what replicas are for: a shared test or demo environment that has to stay up, not load.
- The README links these release pages as the changelog.
Tested with the fiori-devstack apps on V2 and V4, on Docker Compose: 117,015 JPY beside 5,019.71 GBP in both list reports, and the apps' OPA tests, with the draft sample on PostgreSQL 18.6.
Upgrading
- Generated amounts in a currency without two decimals change, and so do the totals of their orders. A test that expects one of the old values needs the new one. Amounts in EUR, USD, GBP or CHF with a
Scaleof 2 are as they were. - A generated amount with a
Scaleof 3 or more now has two decimals in a two-decimal currency.
Install
npx odata-prova@0.24.1 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.24.1Details
v0.24.0: safer writes, stricter filters, enums by value
What's new
PUT [] no longer wipes a row
A PUT whose body was an array was read as an entity with no properties, so every property was reset, and the client got a 204. Inside a $batch, the array was turned into an object first, so a PATCH [] was a silent 204 and a POST [] complained about a missing key.
PUT /odata/v4/MySrv/Items(1)
[]
Now it's a 400 with Request body must be a JSON object, directly and in a $batch, in V4 and V2, on drafts too. The row stays as it was.
Renaming a draft child no longer deletes it
A PUT on a draft child with only {"title": "Renamed"} reset its link to the parent, so the child left the draft. Activating then deleted the active child, although the client had only renamed it.
The columns that hold a child in its draft are now the server's: they keep their value through a PUT, a PATCH, or a link. HasDraftEntity is also right at every step: an active child says false as soon as its draft is deleted, and after a discard.
Links follow the draft rules
A $ref, a $links or a bind could change an active entity directly, which a PATCH can't. Now it's a 400, change its draft, not the active entity. A link held elsewhere leaves the entity as it is, so a row outside the draft can still point at an active entity, by its own foreign key or through a many-to-many link.
A bind that disagrees with a foreign key in the same update is a 400 too, including a bind that removes the link while the body sets the key.
Enums compare by value
Enums were compared by the way they were spelled, so R,W, W,R and 3 were different values. Now an enum is its number, in $filter, $orderby and groupby:
Pm eq F.Perm'R,W'finds rows saved asW,Ror3- members with no
Valueare numbered from 0, each after the one before IsFlagstypes work up to the full 64 bits- two members of one value are one group in
groupby
A flags value is held one way, so with a member RW=3, a client that writes R,W reads back RW.
A member Value that isn't a whole number stops the start, rather than failing later on a $orderby:
metadata.xml: F.Color.Red: Value "abc" is not a whole number
Filters into complex values
Addr/City eq 'Athens' was a 400, Cannot filter on path Addr/City. $filter and $orderby now follow paths through single complex values, at any depth, through navigations and in lambdas:
$filter=Addr/City eq 'Athens'
$filter=Place/Stops/any(p:p/Addr/City eq 'Rome')
$orderby=Customer/Addr/City desc
A null Addr gives null, so Addr/City eq null matches its row.
A filter that can't mean anything is a 400
These used to return rows, or no rows, with no sign that anything was wrong. Each is now a 400, whatever rows there are, and the message doesn't quote row data:
| Request | Why |
|---|---|
$filter=Qty, not Qty, Qty and true |
A filter has to be a condition, at every level |
Kids/any(k:k/ID) |
So does a lambda's body |
Tags eq 'a', Tags has 'a', Addr eq 'x' |
A collection or a complex value only compares with null |
Qty eq F.Color'Red', Col eq Sh |
Another type's enum isn't a value of this one |
Qty has 1 |
has needs an enum |
Qty eq 'abc' |
Text compared with a number has to be one |
$orderby=Tags, $orderby=Addr |
Neither has a value to sort by |
Options that were ignored are refused
PATCH ?$select=Nope was a 204, and the write applied. Options on a write are now checked before anything changes, and options that don't apply to a request are a 400: $count=true on an entity or a property, $select or $expand on a property, read options on a POST, $select on a DELETE, $skiptoken on one entity. $select that names real properties still works on a write.
$format is checked everywhere: one a resource isn't given in is a 501, as $metadata?$format=json is, since $metadata is XML.
Requests can't hang the server
Some small requests kept the server busy for seconds or longer. A very long number in Pm has 1111… took 20 seconds on 2,000 rows, and it's now refused at once. Long literals, sorts, groups, searches and multiplied rows all count against the work limit now, so they end in a 400, and a long literal is read once, not again for each row. A very large $batch is refused instead of crashing the process, and a hierarchy chain of any depth is answered in linear time.
Values come back as they went in
- Decimals, times and long integers keep every digit in comparisons, keys and groups:
0.3and0.30, orPT1HandPT60M, are one value - every key type round-trips through its URL
- a number past a double's range is a
400:1e400isn'tINF, which is written"INF" length,indexofandsubstringcount characters asMaxLengthdoes: an emoji is one, andsubstringdoesn't cut it in half- a
DefaultValueapplies to a create or aPUTthat leaves the property out. One that isn't a value of its property is ignored, with a line in the startup log - a V2
PUTleaves alone the collections V2 can't see - a required spatial property isn't required, as the server holds none
$counton a collection property counts everything, whatever$topsays
Smaller fixes
- A next link no longer encodes a key twice, and keeps a custom option given twice
- A
$in a URL may be written%24, as in%24metadata, and any method butPOSTon$batchis a405 - A config or JSON data file saved with a byte order mark, as Notepad does, loads
metadata.xmlcan use names such asconstructorfor a namespace or an operation
Data file columns the metadata doesn't have
metadata.xml says what an entity has. A data file's other columns are ignored, and the startup log names them.
Tested with the Fiori sample apps on UI5 1.152.0, on V2 and V4, with V4 drafts on PostgreSQL 18.6, on Docker Compose and on Kubernetes with two replicas.
Upgrading
- A filter,
$orderbyor query option from the table above is now a400instead of an empty or partial answer - An update that sends
Kids: []orGroup: nullis a400when the row has kids or a group: remove links withDELETEon$ref.Group: []is always a400 - A link that changes an active draft-enabled entity is a
400: change its draft $count=trueon a collection property is refused, not ignored$metadata?$format=jsonand V2's$format=atomare a501- An enum
Valuethat isn't a whole number stops the server at startup - A combined flags value reads back in one spelling, which may differ from what was written
Install
npx odata-prova@0.24.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.24.0Details
v0.23.0: stricter OData handling
What's new
A malformed URL could hang the whole server
/Set(' followed by a long run of quotes made the time to parse the path double with every pair of quotes. 56 of them took 25 seconds, and /healthz waited with it, long enough for a liveness probe to kill the pod. The same URL is now a 400 in milliseconds.
Int64 values above 2^53 hit the wrong row
PATCH Bigs(9007199254740993) changed row ...992, answered 204, and DELETE then removed it. I64 eq 9007199254740993 matched both rows. Int64 now keeps every digit in keys, $filter, $orderby, min, max, arithmetic and request bodies, on V2 and V4:
I64 add 1 eq 9007199254740994 the row ...993, and only it
{"ID":9007199254740995} stored as ...995, not ...996
Decimals too: comparisons are exact at any length, as are add, sub, mul and mod. A quotient can't be exact, so div and divby give 15 significant digits.
A write that answered 500 but was saved
A value above U+00FF or a newline can't go in a header, so an ETag holding € or 日本 gave 500 Invalid character in header content ["ETag"], on every read of that row, and on a create that had already saved it. An ETag's non-ASCII characters, " and % are now percent-encoded, in the header and in @odata.etag:
10€ -> W/"10%E2%82%AC"
A blank is a value
ABAP's blank is an empty string, but "" was stored as null: a Nullable="false" property couldn't be blanked (Property Description is required), and $filter=Text eq '' found nothing. "" now stays "" in a string, tells apart from null in $filter, and passes Nullable="false". A JSON data file keeps it too. A CSV cell left empty is still null, and "" for any other type is still null.
Folder names with spaces or non-ASCII characters
My Srv or Müller started normally and printed their URLs, then every request was an HTML 404. They work now, in every URL the server writes, in $batch and in @odata.bind, and the printed URLs can be pasted as they are:
V4: http://localhost:3000/odata/v4/My%20Srv/
Properties named like keywords
Div, Mod, Add, In, Or and Le gave 400 Unexpected token in $filter. True and False were read as literals, so True eq true matched every row. A word is an operator only where an operator can be:
Add add 1 eq 6
In in (5)
True eq true
UI5's V2 model without $batch
With useBatch off, UI5's V2 model sends an update as POST with X-HTTP-Method: MERGE, which answered 405 POST not allowed on an entity. X-HTTP-Method now works for PUT, PATCH, MERGE and DELETE.
Keys compare by value
Decs(1.5) was a 404 for a row stored as 1.50, and 1.5 could then be created as a duplicate. GUIDs were case-sensitive, so a key differing only in case was a second entity, and a foreign key in another case found no parent. Decs(1.5) finds 1.50, either case of a GUID finds its entity, and a duplicate is a 409.
A time is as exact as its Precision, which is all a client can read. 2025-01-01T10:00:00.123Z without a Precision reads back as 2025-01-01T10:00:00Z, and that now finds it, as a key and in $filter.
Enum literals, has and TimeOfDay
Color eq NS.Color'Red'
Perms has NS.Perm'Read,Write'
ByColors(NS.Color'Red')
hour(Tod) eq 12
By namespace or alias, by member name or value. A type or member that doesn't exist is a 400. Enum values in a write are checked against the members too.
Requests that gave a 500, or the wrong answer
/$count,/$valueand/$refalone:404, not500 Cannot read properties of undefinedSet(key)/$count:400, not the whole set's countTags/$count: the collection's size, not the collectionAddr/$value:400, not[object Object]- A system query option given twice:
400, not a500or the values glued together $format=application/json;odata.metadata=minimal:200, not501Dbl eq INF: finds the row- Deep nesting in
$expand,$applyor$search:400, not a stack overflow
$batch
- A
?in a value no longer cuts the URL short "Parent@odata.bind": "$1"names an earlier request of the changeset"Parent@odata.bind": nullremoves a link- A body with no closing delimiter is a
400, and none of it runs. It used to drop the last part in silence
Stricter values
"0x10" is no longer read as 16, and a required field of a complex value is required, at any depth and in a collection (Property Addr/City is required).
Also fixed
- A draft
POSTwith an existing active key is a409 toppercent(-5,...)is a400- Properties named
constructorortoStringno longer store function source text - A schema's alias works in a bound action's name,
Items(1)/Sh.Go - Generated keys stay inside their type: an
Edm.Bytekey gets 255 rows at most, aMaxLength="1"one 9 metadata.xmlin UTF-16, as PowerShell 5.1's>writes it, loads- An entity set named
constructorno longer stops the start
Tested with the Fiori sample apps on UI5 1.152.0, on V2 and V4, with drafts on PostgreSQL 18.6.
Upgrading
""for a string is now kept as"", not null. A client or a JSON data file relying on null gets a blank, andText eq ''no longer matches null. A blank key is still a400- A system query option given twice is a
400, including ones that used to answer200 $counton an entity is a400, where it answered the set's count- A
$batchbody or a changeset with no closing delimiter is a400 - An enum value that isn't a member, a number written in hex, and a missing required field of a complex value are a
400. A data file with an unknown enum member stops the start - A
PATCHreplaces a complex value whole, as it did, so one that leaves out a required field is now a400rather than nulling it - A string with half a surrogate pair is a
400 - A key with the same value as another in a different form,
1.5and1.50, or a GUID in another case, is a409 - A
DateTimeOffsetorTimeOfDaykey without aPrecisioncounts to the second: two in the same second are the same key - A V2 document's time keys without a
PrecisionhavePrecision="3"in the generated V4 metadata, and show their milliseconds on V4 - ETags holding
",%or anything but printable ASCII look different. A client holding an old one gets a412once - A number of 16 digits or more sent for a string property is accepted as text
- A service path without its leading
/, the same path for V2 and V4, or one inside the other, stops the start $expandor$applynested past 1,000 parentheses is a400- Generated rows stop where the key's type does, where an
Edm.Bytekey with more than 255 rows used to stop the start
Install
npx odata-prova@0.23.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.23.0Details
Types, Query options, Paths and options, Keys in URLs, Methods, $batch, Links between entities, ETags
v0.22.1: key and deep-insert fixes
What's new
Keys with a slash, a comma or a question mark
A string key holding a character a URL reserves, as SAP document numbers do (SO/2025/1), wasn't found: the path was decoded without decoding the key, so the server looked for the text SO%2F2025%2F1. And the URIs it wrote for such a key didn't encode it, so following them failed:
GET Docs('SO%2F2025%2F1')
before: 404
now: 200, the document SO/2025/1
GET Docs('50%25') (V2)
before: "__metadata": { "uri": ".../Docs('50%')" } which leads nowhere
now: "__metadata": { "uri": ".../Docs('50%25')" }
Each key value is decoded on its own, so it may hold / , = ? # &, and Location, V2's __metadata.uri and V4's @odata.id encode it.
A deep insert answers with what it created
A create with related entities nested under their navigation created them, but its response left them out, so a client couldn't see their keys or the values the server set. Now the response has them, expanded as deep as the request was, as OData 4.01 asks:
POST PurchaseOrderSet { "PurchaseOrderId": "1", ..., "Items": [ { "ItemPosition": "0001", ... } ] }
before: { "PurchaseOrderId": "1", ... }
now: { "PurchaseOrderId": "1", ..., "Items": [ { "PurchaseOrderId": "1", "ItemPosition": "0001", ... } ] }
V2 has them as "Items": { "results": [...] }.
A V4 function's parameters are checked
A function called without a parameter that can't be null ran with it as null, and one it doesn't have was ignored. Now both are a 400:
GET GetNearestAirport(lat=1)
before: 200
now: 400 RequiredProperty: GetNearestAirport needs its parameter lon
GET GetNearestAirport(lat=1,lon=2,nope=3)
before: 200
now: 400 InvalidParameter: GetNearestAirport has no parameter nope
Parameter values in the path are decoded as keys are.
Upgrading
- A V4 function call that leaves out a parameter with
Nullable="false", or names one the function doesn't have, is a 400. - A path is decoded once:
%25is%.PurchaseOrderSet%25zzis the set namedPurchaseOrderSet%zz, a 404, where it was a 400 for a malformed escape.
Install
npx odata-prova@0.22.1 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.22.1Details: Keys in URLs, Deep insert and Actions and functions.
v0.22.0: value checks, $search expressions
What's new
Values checked against their type
Writes and data files were checked for the type of a value, but not for its range or format, so some values were stored that the type can't hold, or stored as something else:
POST Values {"Small": 300} Edm.Byte
before: 201, stored 300
now: 400 InvalidValue
POST Orders {"OrderDate": "2025-02-30"}
before: 201, stored 2025-03-02
now: 400 InvalidValue
Integers are checked against their type's range, decimals against Precision and Scale, dates against the calendar, and GUIDs, durations, binary and times of day against their format.
Dates in any timezone
A date that isn't ISO 8601 was read by JavaScript's date parser, in the server's own timezone: in a data file on a server in Athens, 2025/03/07 became 2025-03-06, and 07.03.2025 became July 2nd. Now a date is ISO 8601 (2025-03-07, 2025-03-07T10:00:00Z), or with a space for the T and slashes, as spreadsheets write them. Without a zone it's UTC, on every server. Anything else is refused rather than guessed at.
$search, as the spec reads it
$search was one substring. Fiori Elements V4 sends a search field's words quoted, "open" "gmbh", which then matched nothing. Now $search takes the spec's search expression: words and phrases, AND (or a space), OR, NOT and parentheses:
GET PurchaseOrderSet?$search="open" "gmbh"
before: no rows
now: the orders with both words
V2 has no $search. SAP Gateway reads a basic search from search=, which UI5's V2 model sends for a list report's search field. The V2 service read nothing from it, and now reads it as V4 reads $search.
Every digit of an Int64 or a Decimal
Without IEEE754Compatible=true, V4 wrote Int64 and Decimal values as JSON numbers through a double, which rounds them:
GET Values(1)
before: "Big": 9007199254740992, "Amount": 12345678901234567000
now: "Big": 9007199254740993, "Amount": 12345678901234567890.12
A JSON data file's numbers keep every digit too.
Metadata as CAP and RAP write it
A schema alias in a type reference (BaseType="SAP__self.Base") stopped the server from starting. Aliases, TypeDefinitions, binding targets qualified with their container and IncludeInServiceDocument="false" are now read. Singletons aren't served: the startup log lists them, and a navigation to one is a 501 saying why.
And
round()takes a midpoint away from zero.- Durations compare by length.
INFandNaNare now accepted as literals.groupbyandcountdistinctkeep INF, -INF and NaN apart.- An entity's
/$valueis a 501. - A
$batchbody holding the boundary's text is no longer split.
Upgrading
- A data file with a value its type can't hold, or a date that isn't ISO 8601 (
07.03.2025,03/07/2025), stops the start, naming the file. Write dates as2025-03-07. - A system query option the protocol doesn't have is a 400:
$TOP, a misspelt$fliter,$count=truein V2. Custom options such assap-clientaren't affected. $search=foo barfinds the entities with both words, not the textfoo bar. To search for the text, quote it:$search="foo bar".- A Decimal written with an exponent is stored as its digits:
1.5e2is150.
Install
npx odata-prova@0.22.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.22.0Details: Supported OData features (types, query options, search).
v0.21.2: Context URLs of contained entities
What's new
Contained entities' context URLs
A contained entity, one a navigation with ContainsTarget holds and no entity set does (TripPin's Person.Trips), lives in an entity set the server makes for it. Its responses named that set in their context URL: $metadata#People-Trips(Name), which is in no $metadata, so a client resolving the context found nothing. Now the context is the path through the parent, as the OData spec writes it for contained entities:
GET People('russellwhyte')/Trips?$select=Name
before: "@odata.context": ".../$metadata#People-Trips(Name)"
now: "@odata.context": ".../$metadata#People('russellwhyte')/Trips(Name)"
GET People('russellwhyte')/Trips(1)
now: "@odata.context": ".../$metadata#People('russellwhyte')/Trips/$entity"
The same for nested ones (People('ben')/Trips(1)/PlanItems), $apply results and a created entity's response.
Upgrading
- A V4 response for contained entities has another
@odata.context, as above. Nothing else changes: the entities, their URLs andLocationwere already the paths through their parents. V2 has no containment.
Install
npx odata-prova@0.21.2 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.21.2Details: Navigations without a ReferentialConstraint (containment).
v0.21.1: No orders without items
What's new
Every order has items
In 0.21.0, generated items picked their order at random, so about half the orders had none, and still showed a total with nothing behind it. No SAP document is without items. Now a set whose key holds its parent's, as SAP Gateway and RAP model them (PurchaseOrder + PurchaseOrderItem, SalesOrder + SalesOrderItem, Travel + Booking), gets 1 to 5 rows under each parent, and every order's total is the sum of its items:
PurchaseOrderSet: 20 rows generated (no seed file)
PurchaseOrderItemSet: 58 rows generated (no seed file)
Recipes, and examples with mock rules
- Recipes: the commands for trying a service with
curl, running it withnpxand Docker (--explainand--write-dataincluded), Docker Compose, and CI. - The examples show the mock rules: Northwind has a
config.jsonthat fixes its filler values, and PurchaseOrderSrv is now all generated, with rules next to its operation.
Upgrading
- An item set without a data file gets 1 to 5 rows per parent, not
--mock-rows: about three times as many rows. Tests that count generated items will see the difference. - With
--persist, the next start regenerates the generated orders and items nothing has written to, and logs it. Sets with your writes are kept. - Items keyed by an ID of their own (CAP's compositions), or by two parents (Northwind's
Order_Details), are still spread at random, as before.
Install
npx odata-prova@0.21.1 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.21.1v0.21.0: Live mock rule changes
What's new
Mock rules change while the server runs
In 0.20.0, a change to the mock rules in config.json showed only after a restart, and the restart dropped every write made since. Now the server watches config.json, and the files it extends: save a rule, refresh the app, and the generated rows follow it. The log says what was done:
MySrv/config.json: mock rules changed
Shippers: regenerated
Categories: has your changes, kept (restart to regenerate it)
- Your writes are kept. A set changed by a write since the start keeps its rows. A write that failed, such as a
$batchchangeset rolled back, doesn't count. - References stay valid. When the new rules change a set's keys, the rows that point at it are regenerated with it. If those rows have your changes, the set is kept instead:
Orders: kept, Order_Details refers to it and has your changes. - Only the sets that come out different are replaced. Their delta links answer
410 Gone, as after a restart. - A mistake doesn't stop the server. It's logged with how to fix it, and the rows stay as they were:
MySrv/config.json: a mock rule that doesn't fit the model:
mock "Shippers.CompnyName": Shippers has no property CompnyName. Did you mean "CompanyName"?
The rows are as they were: fix it and save again
A config.json created after the start is picked up too, so pasting the block --explain proposes into a new file works without a restart.
Saved data keeps up with the rules
With --persist, the generated rows were saved at the first start and never generated again: a changed rule showed only after --persist-reset, which dropped your writes too. Now each start generates the saved generated sets again, and replaces the ones that come out different, keeping the sets with your writes:
Saved state: loaded from MySrv.db (the rows above are not used)
The mock rules or the generator changed since the state was saved:
PurchaseOrderSet: regenerated
PurchaseOrderItemSet: has your changes, kept (--persist-reset to regenerate it)
The same happens when --mock-rows changes, or a new version generates rows differently. A set whose keys would change under rows with your writes that point at them is kept, as when the server runs. With replicas on PostgreSQL, the first server that starts regenerates, and the others load what it saved. Two servers starting at once agree on one state.
The rules apply at the next start, not while the server runs: several servers sharing a database would each regenerate.
Fixes
Found by fuzz testing: random rules, requests, metadata documents, data files, command lines and file edits, against every example and test model.
- A data file with two rows of the same key was loaded, and with
--persistone of them was lost at the next start. The start now says which rows:Orders.csv: rows 2 and 7 have the same key, ID 4. - A resource path with characters no segment has was read as another path:
Products(1)CategoryasProducts(1)/Category, and a lone(was a 500. Both are now a400. - A
Locationfor a key with a line break, a space or a non-ASCII character was a 500. It's now percent-encoded, and leads to the entity. - A metadata.xml that can't be used stopped the start with
Cannot read properties of undefined. It now says what's wrong:metadata.xml: EntityType Orders: Property OrderNo has no Type, a key that names no property, a set whose type has no key, XML that isn't well-formed (with its line). - A JSON data file that isn't a list of rows crashed the start. It now says so, with the row.
- Mock rules that can't fit are refused at the start with why: a date that doesn't exist (
2025-02-30), a number out of an integer's range or over a Decimal's Precision, or""on a property that can't be empty. - Generated rows: a set whose key is its parent's whole key (a product's detail) left some of its rows pointing at nothing; a Binary key is generated, where it was empty.
Upgrading
- Without
--persist, a running server watches its model folder, and the folders of the filesconfig.jsonextends. Saving changed mock rules regenerates the sets nothing has written to. - A regenerated set's delta links answer
410 Gone. Clients read the set again, as after a restart. - With
--persist, a start regenerates the saved generated sets that have no writes, when the rules,--mock-rowsor the generator changed. Tests that relied on saved generated rows staying as first generated will see the new ones. - A state saved by 0.20.0 or before doesn't record which sets are as generated: its sets are all kept. Start once with
--persist-resetfor the rules to apply from then on. It drops your writes. - A data file with two rows of the same key, or a JSON data file that isn't a list of objects, now stops the start, naming the rows.
- A path like
Products(1)Category, which was served asProducts(1)/Category, is now a400. - Mock rules that were accepted and generated values that don't fit (an impossible date, an Int16 of 40000) now stop the start with what's wrong.
- A set whose key is its parent's whole key (1:1) gets one row per parent: its generated rows differ from 0.20.0.
- A change to
operations,metadata.xmlor a data file still needs a restart. - Used as a library,
createAppdoesn't watch unless givenwatchRules: true.
Install
npx odata-prova@0.21.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.21.0Details: Changing rules while the server runs, With --persist, Keeping the data.
v0.20.0: Realistic mock data, with rules and --explain
What's new
Generated rows that agree with each other
Each column used to be generated on its own, so a Fiori app on mock data showed an order in CHF with items in EUR, a city in Vienna with a country of Netherlands, a total unrelated to its items, and an order shipped months before it was placed. Now a row's columns come from one place and one product, and an order's items agree with it:
PurchaseOrderId;Supplier;CompanyCode;OrderDate;Status;Currency;TotalAmount
4500000002;Stark Manufacturing;1810;2025-04-23;Completed;JPY;552.74
PurchaseOrderId;ItemPosition;Material;Quantity;Unit;NetPrice;Currency
4500000002;00010;Hex Bolt M8;44.000;PC;0.89;JPY
4500000002;00020;Hydraulic Oil;44.312;L;11.59;JPY
- A row's city, postal code (in its country's format), region, country, currency and company code come from one location. Its material, unit and price come from one product.
- Pieces are counted and litres measured:
44.000 PC,44.312 L. - The metadata decides which column is an amount's currency or a quantity's unit when it says so: V2's
sap:unitandsap:semantics, V4'sMeasures.ISOCurrencyandMeasures.Unit. - A row's dates are in order: the change, delivery and due dates are later than the creation and order dates. Documents created later have higher numbers. Validity ends are
9999-12-31. - An order's items take its currency, company code and plant, and are numbered by 10 (
00010,00020). The order's total is the sum of its items. - No more humanized names cut short: a 4-character
Extensionused to beExte, and is now 4 digits.
SAP's number ranges, built in
Standard SAP field names get SAP's standard ranges, by their RAP names and their DDIC names alike. Purchase orders (PurchaseOrder, Ebeln) are 4500000001, sales orders 0000000001, suppliers 17300001, customers 17100001, materials TG01. A key named ID follows its entity type's name, so A_PurchaseOrderType.ID is a purchase order number. Suppliers and customers get a number only where the column is ID-sized: a 100-character Supplier keeps its company name.
Change a column in config.json
When a column is still off, a mock section in the service's config.json changes it. The value's shape is the rule:
{
"mock": {
"PurchaseOrderSet.Status": ["Open", "Open", "Approved"],
"PurchaseOrderSet.ZzProject": "PRJ-####",
"TotalAmount": "100..50000",
"Currency": "EUR"
}
}#s are a running number, .. a range of numbers or dates, a list is picked from (a value repeated is more likely), and anything else is a constant. "Set.Property" is for one entity set, "Property" for every set that has it, and "Address/City" for a complex property's member. "extends": "../shared/config.json" shares rules, and operations, across services.
A rule that doesn't fit the model stops the start, with every mistake listed and how to fix it:
/models/MySrv/config.json: 2 mock rules that don't fit the model:
mock "PurchaseOrderSet.Staus": PurchaseOrderSet has no property Staus. Did you mean "Status"?
mock "PurchaseOrderSet.Currency": "EURO" is 4 long, MaxLength is 3
--explain proposes the rules
At startup, the server says when generated columns are still on filler values:
3 properties use filler values: add --explain to see them, and what to put in config.json
npx odata-prova ./MySrv --explain lists them, with their label and a sample, and a mock block to paste and edit:
3 properties use filler values:
Employees.Extension "Extension" Extension 1
Invoices.CustomerID "Customer ID" 703510
Orders_Qries.CustomerID "Customer ID" 292111
To change them, add to config.json:
"mock": {
"Employees.Extension": ["...", "..."],
"Invoices.CustomerID": ["...", "..."],
"Orders_Qries.CustomerID": ["...", "..."]
}
--explain all shows how every property is generated, and which rule or file decides it.
--write-data on the main command
npx odata-prova ./MySrv --write-data writes the generated rows to data/, to edit them, following the config.json rules, so nobody has to remember a second command. odata-prova-mock-data still works, and follows the rules too.
Upgrading
- Generated rows differ from 0.19.0: other values, dates and amounts. Tests that compare generated values will see diffs. To keep the old rows, write them to files with 0.19.0:
npx -p odata-prova@0.19.0 odata-prova-mock-data ./MySrv. - Keys in SAP's ranges change: a generated
PurchaseOrderIdof0000000001is now4500000001, and a new draft gets the number after the highest,4500000021. Bookmarks and test URLs with the old keys answer 404. - With
--persist, the saved rows are kept. The new ones appear after--persist-reset, which also drops your writes. - A
config.jsonwith amocksection that doesn't fit the model now stops the start. Mistakes inconfig.jsonprint without a stack trace. - The server prints one more line at startup when generated columns are on filler values.
Install
npx odata-prova@0.20.0 ./MySrv
docker run -p 3000:3000 -v "$PWD/MySrv:/models/MySrv:ro" ghcr.io/jaravan/odata-prova:0.20.0Details: Mock data, Changing a column, Rule values, SAP's field names.