dice icon indicating copy to clipboard operation
dice copied to clipboard

Fix LPOP to support multiple arguments #1100

Open tren03 opened this issue 1 year ago • 3 comments

This pull request addresses issue #1100, where the LPOP command needed to support an additional argument to specify the number of elements to pop from the left side of the list.

Changes: Modified the LPOP command to accept either 1 or 2 arguments: LPOP key: Pops a single element from the list (default behavior). LPOP key count: Pops up to count elements from the list.

Validation: If count is 0, an empty response is returned.

If count is negative, an "out of range" error is returned. If count exceeds the number of available elements, it pops as many elements as available without error. Invalid count (non-integer values) returns an appropriate error. Popping from a non-existent or empty list returns nil.

Behavior: Returns a single element if one element is popped. Returns a list of elements if multiple elements are popped.

This is the dicedb output dice-output

This is the output for redis over the same commands redis-output

tren03 avatar Oct 15 '24 20:10 tren03

Thanks for the fix! It would be great to have unit and integration tests validating these changes.

Thanks :), Yep I am on it.

tren03 avatar Oct 16 '24 12:10 tren03

this is the unit-tests unittest

this is the integration tests integrationtest

any changes to make?

tren03 avatar Oct 16 '24 16:10 tren03

Hey, Its been a while since I heard back. I saw that there was a slight conflict with my branch, so i fixed it with a merge. Would love to get some updates on this issue.

tren03 avatar Oct 25 '24 03:10 tren03

Hey, Its been a while since I heard back. I saw that there was a slight conflict with my branch, so i fixed it with a merge. Would love to get some updates on this issue.

whoops, didn't realise the comments were addressed. Going through this PR.

JyotinderSingh avatar Oct 29 '24 13:10 JyotinderSingh