Code Monkey home page Code Monkey logo

Comments (3)

alenkordic avatar alenkordic commented on July 4, 2024 2

@techniq We also encounter the same issue here. Using version 7.0.3.
Nested query object with multiple props on the same level, using odata "in" operator, create a duplicated query string. Duplication happens as many times as the number of props on the same level (3 props = 3 duplications).
Looking forward for solution. Thank you.

import buildODataQueryFn from 'odata-query';

const query = {
  filter: {
    components: {
      control_number: {
        in: ['0158'],
      },
      component1_number: {
        in: ['0179'],
      },
      component2_number: {
        in: ['0187'],
      },
    },
  },
};

const queryString = buildODataQueryFn(query)

console.log(queryString)

// ?$filter=components/control_number in ('0158') and components/component1_number in ('0179') and components/component2_number in ('0187') and components/control_number in ('0158') and components/component1_number in ('0179') and components/component2_number in ('0187') and components/control_number in ('0158') and components/component1_number in ('0179') and components/component2_number in ('0187')

from odata-query.

anton-kirschhock avatar anton-kirschhock commented on July 4, 2024

Can confirm, we've got the exact same issue here:

let filter = {
    users: {
      firstName: { contains: 'admin' },
      isActive: { eq: true },
    },
    not: { users: { roles: { any: {} } } },
};

buildQuery({ filter });

results in:

"?$filter=contains(users/firstName,'admin') and users/isActive eq true and contains(users/firstName,'admin') and users/isActive eq true and not(users/roles/any())"

from odata-query.

techniq avatar techniq commented on July 4, 2024

I'd be happy to review a PR, but to be honest, I don't have much time to dig into the issue.

from odata-query.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.