-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: func isEmptyValue support time.Time #3273
base: master
Are you sure you want to change the base?
Conversation
@gh73962 Thank you for the contribution. The test that you have added would have passed with or without the addition you did. Can we check what will be read so we verify the data. Maybe a raw read would work, since if we unmarshal the response to the object it would be the same as before, won't it? |
Of course, I don't have the capability to perform this kind of test on my side. Changes like this should have comprehensive tests to ensure code quality. |
@gh73962 would you like me to help you add those tests? The CI will run a redis server, you should be able to execute code agains it in the tests (you can check the existing tests for Set and Get). Let me know if I can help you somehow. |
Of course |
@gh73962 any concrete questions on how to write tests? will you be able to do this on your own? |
In my first commit of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR adds support in the isEmptyValue function to correctly handle time.Time values by leveraging Go’s reflect.IsZero.
- Updated commands.go to use v.IsZero() for reflect.Struct to check for zero values.
- Extended commands_test.go with a new test struct (set2) including a time.Time field to validate the new functionality.
Reviewed Changes
File | Description |
---|---|
commands.go | Added reflect.Struct case using v.IsZero() for isEmptyValue. |
commands_test.go | Added a test struct with a time.Time field to exercise the new functionality. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
commands_test.go:2581
- Consider adding a test case where the time.Time value is set to a non-zero value to confirm that non-empty time values are handled correctly.
Set5 time.Time `redis:"set5,omitempty"`
commands.go:156
- Review whether applying v.IsZero() to all structs might have unintended consequences for non-time.Time types. If this branch is intended only for time.Time support, consider verifying or isolating behavior for other struct types.
case reflect.Struct:
This PR is based on the solution discussed in the #3208 issue.