Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of isof function #116

Open
girlpunk opened this issue Feb 12, 2024 · 1 comment
Open

Support of isof function #116

girlpunk opened this issue Feb 12, 2024 · 1 comment

Comments

@girlpunk
Copy link

OData version 4 introducses support for the isof function. Documentation is available at https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31361017, however implementation should be fairly straightforward.

@bodia-uz
Copy link
Owner

From the doc:

Example 95: orders that are also BigOrders
http://host/service/Orders?$filter=isof(NorthwindModel.BigOrder)
http://host/service/Orders?$filter=isof($it,NorthwindModel.BigOrder)

Example 96: orders of a customer that is a VIPCustomer
http://host/service/Orders?$filter=isof(Customer,NorthwindModel.VIPCustomer)

If I understand correctly, .fn should solve it:

// isof(Customer,NorthwindModel.VIPCustomer)
const filter = f()
  .fn('isof', 'Customer', 'NorthwindModel.VIPCustomer', false);

// isof(NorthwindModel.BigOrder)
const filter = f()
  .fn('isof', 'NorthwindModel.BigOrder', undefined, false);

describe('fn', () => {
it('substringof', () => {
const filter = f()
.fn('substringof', 'Name', 'John', true, true);
expect(filter.toString())
.toBe("substringof('John', Name)");
});
it('substringof + toLower', () => {
const filter = f()
.fn('substringof', x => x.toLower('Name'), 'john', true, true);
expect(filter.toString())
.toBe("substringof('john', tolower(Name))");
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants