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

OR-Filter on Property & NavigationProperty #1338

Closed
HeneryHawk opened this issue Jun 6, 2021 · 10 comments
Closed

OR-Filter on Property & NavigationProperty #1338

HeneryHawk opened this issue Jun 6, 2021 · 10 comments
Assignees
Labels
bug Something isn't working prio: high

Comments

@HeneryHawk
Copy link

Hi @jjtang1985

Creating a filter query consisting of two filters, one on an entity property and one filter on a NavigationProperty, which are associated with an OR expression, results in an error.

I want to create the following oData filter:
$filter=(Id eq <id> or (ExternalIds/any(a0:(a0/ExternalId eq '<id>'))))

This should be done by the following code:

.filter(or(Entity.ID.equals(id), Entity.EXTERNAL_IDS.filter(any(ExternalIds.EXTERNAL_ID.equals(id)))))

But unfortunately the TypeScript compiler returns the following error message:

Argument of type 'OneToManyLink<Entity, ExternalIds>' is not assignable to parameter of type 'Filterable<Entity>'.
  Type 'OneToManyLink<Entity, ExternalIds>' is missing the following properties from type 'Filter<Entity, FieldType | FieldType[]>': field, operator, valuets(2345)

However, linking both filters with an AND expression works fine

.filter(Entity.ID.equals(id), Entity.EXTERNAL_IDS.filter(any(ExternalIds.EXTERNAL_ID.equals(id))))

$filter=(Id eq <id> and (ExternalIds/any(a0:(a0/ExternalId eq '<id>'))))

See also the question on the SAP Community.

Used Versions:

  • SAP Cloud SDK: 1.44.0

Regards
Simon

@HeneryHawk HeneryHawk added the bug Something isn't working label Jun 6, 2021
@jjtang1985
Copy link
Contributor

Hi @HeneryHawk ,

thanks for approaching us in this repo.

I could reproduce this issue so I created a backlog item.

Could you please share your time line and your project status?
Are you working on a PoC project or live system?

Best regards,
Junjie

@HeneryHawk
Copy link
Author

Hi @jjtang1985,
thank you for your efforts.

The feature that includes this functionality of the Cloud SDK should be delivered to our customers shortly.
The feature will work in its entirety, but a part of it is affected by this Cloud SDK bug. So this non working part will have to be delivered afterwards, as soon as a bugfix for the Cloud SDK is available.

In a nutshell:
The sooner a bugfix for the Cloud SDK is available, the better it is for us, as we can then complete the feature.

Best
Simon

@jjtang1985
Copy link
Contributor

Hi @HeneryHawk ,

thanks for sharing the status of your current project.

@artemkovalyov , let's make a high priority for this.

Best regards,
Junjie

@jjtang1985
Copy link
Contributor

Hi @HeneryHawk ,

sorry for the missing update here.

The fix #1356 was merged 3 weeks ago and we released a new version 1.46.0.
Please feel free to test it and share the result.

I'll close this ticket.
Please reopen if it does not solve your issue.

@HeneryHawk
Copy link
Author

HeneryHawk commented Jul 5, 2021

Hi @jjtang1985,

I have tested the new version, but I get the following error:
Could not construct query parameters from filter. Filter is not valid

.filter(or(Entity.ID.equals(id), Entity.EXTERNAL_IDS.filter(any(ExternalIds.EXTERNAL_ID.equals(id)))))

If the filters are passed without the or-expression (generates an and expression by default), the generation of the filters works. Only if I want to link the two filters with an or-expression, I get this error.

.filter(Entity.ID.equals(id), Entity.EXTERNAL_IDS.filter(any(ExternalIds.EXTERNAL_ID.equals(id))))

The code compiles now, but causes a runtime error during execution.
Can you please check this again?

Regards
Simon

PS: The filters.spec.ts only tests an and-expression of several filters. But in my case it is an or-expression.

@HeneryHawk
Copy link
Author

Hi @jjtang1985,

can you please reopen this issue as I can't do that.
Please see my comment above.

Regards
Simon

@jjtang1985
Copy link
Contributor

jjtang1985 commented Jul 9, 2021

Hi @HeneryHawk ,

I'm sorry to hear the bug still exists.

I reopened the ticket as I can reproduce the issue by using the following filter.

or(
  TestEntityV4.STRING_PROPERTY.equals('str'), 
  TestEntityV4.TO_MULTI_LINK.filter(
    any(TestEntityMultiLinkV4.STRING_PROPERTY.equals('str2')
  )
)

To developers: we should add this case to the filter-factory.

The ticket is on the top of our current sprint and will be treated as highest priority.

@jjtang1985
Copy link
Contributor

Hi @HeneryHawk ,

the runtime error is fixed and please feel free to try the canary version of the sdk core.
Please let me know your feedback.

We might release a new stable version next week.

Best regards,
Junjie

@HeneryHawk
Copy link
Author

Hi @jjtang1985,

I tested the fix with the canary version and now everything seems to work.
Thanks for your efforts and the quick fix. If something comes up again, I will open a new issue.

Best regards,
Simon

@jjtang1985
Copy link
Contributor

Ok, I'll close this issue then.
Thanks for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prio: high
Projects
None yet
Development

No branches or pull requests

2 participants