Code Monkey home page Code Monkey logo

Comments (4)

techniq avatar techniq commented on June 7, 2024

You could turn indexof(tolower(Name), 'gead') into a string like so:

{
  filter: {
    Item: {
      any: {
        "indexof(tolower(i/Name), 'gead')": {
          eq: -1
        }
      }
    }
  }
}

You can past that into this sandbox and see the output:

"?$filter=Item/any(i:indexof(i/tolower(i/Name), 'gead') eq -1)"

although I just noticed it added i/tolower and not just tolower. This might be due to how that sandbox is written to JSON.parse the input values. Give it a try in your code and let me know.

If you need to interpolate the 'gead' value, you should be able to like so:

{
  filter: {
    Item: {
      any: {
        `indexof(tolower(i/Name), ${someVal})`: {
          eq: -1
        }
      }
    }
  }
}

from odata-query.

fabio-b avatar fabio-b commented on June 7, 2024

I'm using it as a string, I must've not formatted the original post correctly.

Taking your suggestion with adding the variable manually it ends up not respecting that variable.
filter=((PROJECT/any(p:indexof(p/tolower(p/Name), 'te') eq -1)))

It seems to do the same as what the sandbox is doing.

from odata-query.

techniq avatar techniq commented on June 7, 2024

Hmm, just took a quick look, and it appears we prefix any parameters within a function using this regex, which is why p/tolower is being prefixed from the nested functions.

I'm not sure of a clean solution at this point, and have moved away from OData for my current projects to GraphQL so don't have a direct need. If you can find a solution that doesn't break the other use cases, I'm happy to review a PR and merge/release.

from odata-query.

fabio-b avatar fabio-b commented on June 7, 2024

Hmm ok, I'll ponder this too and get back.

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.