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

Issue with not operator inside collection filter #98

Open
jjavierdguezas opened this issue Oct 29, 2021 · 0 comments
Open

Issue with not operator inside collection filter #98

jjavierdguezas opened this issue Oct 29, 2021 · 0 comments

Comments

@jjavierdguezas
Copy link
Contributor

jjavierdguezas commented Oct 29, 2021

I have the following scenario:

class User {
 id: string;
 [...]
 teams: Member[];
}

class Member {
 userId: string;
 user: User;
 teamId: string;
 team: Team;
}

class Team {
  id: string;
  title: string;
  [...]
}

and doing:

import buildQuery  from "odata-query";

let query = buildQuery({
  filter: {
    Teams: {
      all: {
        and: [
          {
            "Team/Title": {
              contains: "team1",
            },
          },
          {
            not: {
              "Team/Title": {
                contains: "team2",
              },
            },
          },
        ],
      },
    },
  },
});

console.log(query);

I expect:
?$filter=Teams/all(teams:((contains(teams/Team/Title,'team1')) and (not contains(teams/Team/Title,'team2'))))

but odata-query produce an invalid query:
?$filter=Teams/all(teams:((contains(teams/Team/Title,'team1')) and (contains(teams/not/Team/Title,'team2'))))

as you can see teams/not/Team/Title is wrong

Is this an issue or is there a way to achieve the expected query?

thanks in advance

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

1 participant