Skip to content

Json toggle helper added - #314

Merged
gkorland merged 4 commits into
RedisJSON:masterfrom
ashifa454:ashifa454/bool_toggle
Apr 22, 2021
Merged

gkorland merged 4 commits into
RedisJSON:masterfrom
ashifa454:ashifa454/bool_toggle

Conversation

@ashifa454

Copy link
Copy Markdown
Contributor

New Helper method is added to toggle the boolean value

  • if the provided path is unavailable it returns null
  • if the provided path is not boolean it returns a type error
  • if the provided path is boolean it returns the toggled value as a string

@CLAassistant

CLAassistant commented Apr 21, 2021 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ashifa454
ashifa454 force-pushed the ashifa454/bool_toggle branch from 0dcee2c to 7b7fcc1 Compare April 21, 2021 06:46
@ashifa454

Copy link
Copy Markdown
Contributor Author

@gkorland can you please help me with this check?

@gkorland
gkorland requested a review from oshadmi April 21, 2021 13:37
@ashifa454
ashifa454 force-pushed the ashifa454/bool_toggle branch from c40aae6 to 1ce0798 Compare April 22, 2021 06:50
Comment thread tests/pytest/test.py
"""Test REJSON.TOGGLE command"""
r = env
r.assertOk(r.execute_command('JSON.SET', 'test', '.', '{"foo":true}'))
r.assertEqual(r.execute_command('JSON.TOGGLE','test','.foo'), 'false')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would add another toggle to 100% verify the alternation
r.assertEqual(r.execute_command('JSON.TOGGLE','test','.foo'), 'true')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@ashifa454
ashifa454 requested a review from oshadmi April 22, 2021 08:25

@oshadmi oshadmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool!
LGTM
👍🏼

@oshadmi

oshadmi commented Apr 22, 2021

Copy link
Copy Markdown
Collaborator

Hi @MeirShpilraien,
Regarding CRDT - this new JSON.TOGGLE command would be supported by CRDT, right?
(Assuming BITOP XOR is)

@gkorland
gkorland merged commit ffe62dd into RedisJSON:master Apr 22, 2021
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

Successfully merging this pull request may close these issues.

4 participants