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

Java: JSON.OBJLEN and JSON.OBJKEYS. #2492

Merged
merged 8 commits into from
Oct 24, 2024
Merged

Conversation

Yury-Fridlyand
Copy link
Collaborator

Issue link

#2430

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Commits will be squashed upon merging.

Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand added the java issues and fixes related to the java client label Oct 21, 2024
@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner October 21, 2024 22:56
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
* assert Arrays.equals((Object[]) res, new Object[][] { { "a", "b", "c" } }); // key names as a nested list for objects matching the JSONPath `$.b`.
* }</pre>
*/
public static CompletableFuture<Object[]> objkeys(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objkeys returns an array is all cases? well at least one of the commands acts decently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object[][] for JSONPath and Object[] for legacy path. So common denominator is Object[].

assertEquals(2L, res);
res = Json.objlen(client, gs(key)).get();
assertEquals(2L, res);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we test when the path doesn't exist, or the path is not an array, or the key is not JSON?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I don't want to start testing module instead of client.

res = Json.objkeys(client, key).get();
assertArrayEquals(new Object[] {"a", "b"}, res);
res = Json.objkeys(client, gs(key)).get();
assertArrayEquals(new Object[] {gs("a"), gs("b")}, res);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we test when the path doesn't exist, or the path is not an array, or the key is not JSON?

@acarbonetto acarbonetto merged commit b44368e into release-1.2 Oct 24, 2024
14 checks passed
@acarbonetto acarbonetto deleted the java/yuryf-valkey-449 branch October 24, 2024 19:43
prateek-kumar-improving pushed a commit that referenced this pull request Oct 25, 2024
* `JSON.OBJLEN` and `JSON.OBJKEYS`.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
BoazBD pushed a commit to BoazBD/valkey-glide that referenced this pull request Oct 27, 2024
* `JSON.OBJLEN` and `JSON.OBJKEYS`.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: BoazBD <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants