| 937 | |
| 938 | @pytest.mark.redismod |
| 939 | def test_objkeys_dollar(client): |
| 940 | client.json().set( |
| 941 | "doc1", |
| 942 | "$", |
| 943 | { |
| 944 | "nested1": {"a": {"foo": 10, "bar": 20}}, |
| 945 | "a": ["foo"], |
| 946 | "nested2": {"a": {"baz": 50}}, |
| 947 | }, |
| 948 | ) |
| 949 | |
| 950 | # Test single |
| 951 | assert client.json().objkeys("doc1", "$.nested1.a") == [["foo", "bar"]] |
| 952 | |
| 953 | # Test legacy |
| 954 | assert client.json().objkeys("doc1", ".*.a") == ["foo", "bar"] |
| 955 | # Test single |
| 956 | assert client.json().objkeys("doc1", ".nested2.a") == ["baz"] |
| 957 | |
| 958 | # Test missing key |
| 959 | assert client.json().objkeys("non_existing_doc", "..a") is None |
| 960 | |
| 961 | # Test non existing doc |
| 962 | with pytest.raises(exceptions.ResponseError): |
| 963 | assert client.json().objkeys("non_existing_doc", "$..a") == [] |
| 964 | |
| 965 | assert client.json().objkeys("doc1", "$..nowhere") == [] |
| 966 | |
| 967 | |
| 968 | @pytest.mark.redismod |