Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Make module buildable; deal better with missing properties #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TimWynsma
Copy link

package.json
The odata-v4-inmemory module would not build because the format of the *.d.ts file had changed with the newer typescript that was used to build the requirement module odata-v4-parser. Updated both the typescript version and the minimum version of odata-v4-parser. Not sure if it was necessary to update the latter, but it should not hurt.

test/filterVistor.test.js:
Once I was able to get the module to build, there were four tests that were failing. Disabled them because they were failing before I changed anything.

src/FilterVisitor.ts
Updated function VisitODataIdentifier so it can deal better with properties that are undefined. At the point at which this function is called, a property could be set to null, but it could also be undefined. In order for filtering and sorting to work properly in those cases, the code now forces a return of null if the property is undefined (rather than returning undefined). This enables queries like the following to return the expected result:

http:///odata/worker?$filter=strProperty eq null

NOTE: in the system I am working with, the OData service is querying micro-services to get their data. They return json when null properties are not included. Hence VisitODataIdentier would return undefined when they were accessed.

…test version with which odata-v4-inmemory will build
…of typescript.

Set to use same version as odata-v4-parser. Updated to require latest version of odata-v4-parser
Added comments for each test to indicate why they were being set to skip
… there was no data for the property being accessed, it

would return undefined. This can easily happen if the data is being fetched from another service. OData uses null for unassigned
properties. Returning null instead of undefined fixes a lot of problems that were occuring with filter and sort.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant