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

formatQuery for MongoDB output does not match regular output when using ruleGroups #498

Closed
iskandarreza opened this issue Apr 17, 2023 · 3 comments

Comments

@iskandarreza
Copy link

Hi Jake,

First of all, brilliant component. I love how simple and lightweight it is, and how easy it is to use. I might have found a bug though.

I was testing this on a little personal side project I'm working on and encountered a discrepancy between the output when formatting the query for MongoDB and the component's actual output.

ruleGroup output discrepancy

I was expecting the output for MongoDB to look more like this:

  {
    "$or": [
      {
        "role": {
          "$regex": "front end"
        }
      },
      {
        "location": {
          "$regex": "remote"
        }
      },
      {
        "$and": [
          {
            "keywords": {
              "$regex": "react"
            }
          }
        ]
      }
    ]
  }

I also have a codesandbox here with a minimal reproducible example: https://codesandbox.io/s/quirky-scott-iqrqz1

Thanks!

@jakeboone02
Copy link
Member

Thanks for the kind words! And that's an excellent, detailed report which I very much appreciate. :)

If I remember correctly, this behavior is intentional. formatQuery will, in the "mongodb" case anyway, collapse any groups that only contain one rule down to that rule by itself.

Is it causing a problem? If so, I'm happy to reevaluate that decision.

@iskandarreza
Copy link
Author

Thank you for the quick response.

Oh is that what is going on? Thinking about it, that does make sense for it to do that. Does it cause a problem? Not at the moment, and again when I think about it I don't feel like it will cause a problem. I guess I'll test it out on some data for a bit to confirm that.

Fantastic component though. I'm using it not just to make a user-friendly query GUI for my side project, but also to learn the difference between different db query languages.

@jakeboone02
Copy link
Member

That's fantastic that you're using it as a learning tool. Honestly I never considered that as a use case in and of itself, although I've certainly been using the development of the component as a learning opportunity. Maybe I'll think about putting something more formal together for the docs site.

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