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

Provide a way to ignore the order of array elements #6

Closed
supki opened this issue Jan 23, 2020 · 5 comments
Closed

Provide a way to ignore the order of array elements #6

supki opened this issue Jan 23, 2020 · 5 comments

Comments

@supki
Copy link
Owner

supki commented Jan 23, 2020

No description provided.

@supki
Copy link
Owner Author

supki commented Feb 13, 2020

Probably going to be something like:

{ foo: ~[1, 2, 3] }

to match .foo containing 1, 2, and 3 in some order. I don't want to use the standard set notation ({}) since it clashes with the standard object notation even though it's technically possible to make it work here.

@supki
Copy link
Owner Author

supki commented Feb 18, 2020

The problem here is that, if implemented naïvely, we'd have to check if any permutation of matchers matches the jSON document, which will obviously fuck the performance up.

@supki supki closed this as completed Feb 18, 2020
@supki supki reopened this Feb 18, 2020
@supki
Copy link
Owner Author

supki commented Mar 19, 2020

I think I'm just going to disallow holes as members of unordered arrays instead of trying to figure out a fancy way to support them.

@supki
Copy link
Owner Author

supki commented Mar 19, 2020

It'd also be helpful to provide the user a way to set the comparator. The only real usecase I have is to match the list of rows returned by Postgres in a "random" order without sorting them using the db (this will take way too long in production).

{ foo: (ordered by .id) [{id: 1, name: "bar"}, {id: 2, name: "baz"}]}

should match both {foo: [{id: 1, name: "bar"}, {id: 2, name: "baz"}]} and {foo: [{id: 2, name: "baz"}, {id: 1, name: "bar"}]}

@supki
Copy link
Owner Author

supki commented Mar 19, 2020

Maybe that way we can allow holes as well, but

{foo: (ordered) [1, _, 3]}

will no longer match {foo: [1, 4, 3]} in that case.

supki added a commit that referenced this issue Apr 6, 2022
@supki supki closed this as completed in d33d594 Apr 6, 2022
supki added a commit that referenced this issue Apr 7, 2022
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