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

HOT-FIX: CRITICAL - fixed set command optional arguments and added tests to set command #1508

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

avifenesh
Copy link
Collaborator

#1507
The set command options are not functioning properly.
We found out about it thanks to @Ealenn open an issue.

In order to avoid the repetition of similar bugs, the PR incorporates a fix and a large quantity of tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@avifenesh avifenesh requested a review from barshaul May 31, 2024 14:10
@avifenesh avifenesh requested a review from a team as a code owner May 31, 2024 14:10
@avifenesh avifenesh force-pushed the HotFix/SetWithOption branch 2 times, most recently from b3c51a0 to 6ce9cbc Compare May 31, 2024 14:35
@avifenesh avifenesh requested a review from acarbonetto May 31, 2024 14:35
@avifenesh
Copy link
Collaborator Author

@acarbonetto Please have a look on the tests, see if you think this is a good structure.

@avifenesh avifenesh added bug Something isn't working node Node.js wrapper labels May 31, 2024
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

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

Consider adding UT/IT for all options in options

Copy link
Collaborator

@acarbonetto acarbonetto left a comment

Choose a reason for hiding this comment

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

A couple of comments. I would suggest splitting up your larger test into smaller tests to avoid data conflicts.

node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
@avifenesh
Copy link
Collaborator Author

Consider adding UT/IT for all options in options

@Yury-Fridlyand - Can you explain a bit more? I'm not sure i understand what is the different from the existing tests to what you offer.

@avifenesh avifenesh force-pushed the HotFix/SetWithOption branch from 6ce9cbc to 95a5116 Compare June 1, 2024 04:31
@avifenesh avifenesh requested a review from acarbonetto June 1, 2024 04:31
@Yury-Fridlyand
Copy link
Collaborator

In java client we added UT where we test that all combinations of options are properly converted to command args.

@avifenesh avifenesh changed the title fixed set command optional arguments and added tests to set command HOT-FIX: CRITICAL - fixed set command optional arguments and added tests to set command Jun 2, 2024
@avifenesh avifenesh force-pushed the HotFix/SetWithOption branch 2 times, most recently from 3f6f795 to 0f99d73 Compare June 2, 2024 06:34
@@ -145,13 +145,13 @@ export function createSet(
if (options.expiry === "keepExisting") {
args.push("KEEPTTL");
} else if (options.expiry?.type === "seconds") {
args.push("EX " + options.expiry.count);
args.push("EX", String(options.expiry.count));
Copy link
Collaborator

@barshaul barshaul Jun 2, 2024

Choose a reason for hiding this comment

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

minor: use .toString() instead of String(), it should be guaranteed at this point that count is a number and has the toString built in function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually we have already a check before that count is an int and we dont need recheck it. To me String() is more visually appealing, but if you find it important, i can change.
Normally the decision to take to_string instead of string is when the object you run it on has an override in your class/object of to_string,.

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://courses.bigbinaryacademy.com/learn-javascript/string-methods/tostring-vs-string-method/
I read this blog and it seems like String is for any type of data and toString is to convention for number type, and also it will match what we already have in other commands, which is relevant to have the same conversion to string all over as we're going to change it all to byte-convertor, and it would make it easier to find

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

toString works for object, bool, strings and maybe more. But okay, I'll change. It's not a critical issue.

node/tests/SharedTests.ts Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
@avifenesh avifenesh force-pushed the HotFix/SetWithOption branch from 0f99d73 to e28fcb2 Compare June 2, 2024 11:59
Copy link
Collaborator

@barshaul barshaul left a comment

Choose a reason for hiding this comment

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

See latest comment

@avifenesh avifenesh force-pushed the HotFix/SetWithOption branch from e28fcb2 to 663ad92 Compare June 2, 2024 13:05
@avifenesh avifenesh merged commit adf1e05 into valkey-io:main Jun 2, 2024
8 checks passed
avifenesh added a commit that referenced this pull request Jun 2, 2024
…sts to set command (#1508)

fixed set command optional arguments and added tests to set command
@avifenesh avifenesh deleted the HotFix/SetWithOption branch June 2, 2024 13:25
avifenesh added a commit that referenced this pull request Jun 2, 2024
* fixed CD for last changes

* Change to using json file for our matrix

* Remove issues with many package.json variation in deployed package

* minor fixes

* error looking fix

* fixed adding package.json-e in mac

* added fix to avoid typo in tag to release rc version as real one

* fixed matrix of tests

* added sudo to ts install

* updated to run tests also in real release

* updated README to include supported versions

* return setup node  since tests break when doing it manually

* comments fix

* HOT-FIX: CRITICAL - fixed set command optional arguments and added tests to set command (#1508)

fixed set command optional arguments and added tests to set command

* added 0.4.1 bug fix to changelog

* fix platform_matrix generating

* fix npm notice err

* fix usage of global tsc

* fix usage of global tsc -p
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
…sts to set command (valkey-io#1508)

fixed set command optional arguments and added tests to set command
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
* fixed CD for last changes

* Change to using json file for our matrix

* Remove issues with many package.json variation in deployed package

* minor fixes

* error looking fix

* fixed adding package.json-e in mac

* added fix to avoid typo in tag to release rc version as real one

* fixed matrix of tests

* added sudo to ts install

* updated to run tests also in real release

* updated README to include supported versions

* return setup node  since tests break when doing it manually

* comments fix

* HOT-FIX: CRITICAL - fixed set command optional arguments and added tests to set command (valkey-io#1508)

fixed set command optional arguments and added tests to set command

* added 0.4.1 bug fix to changelog

* fix platform_matrix generating

* fix npm notice err

* fix usage of global tsc

* fix usage of global tsc -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node Node.js wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants