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

feat: func isEmptyValue support time.Time #3273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gh73962
Copy link

@gh73962 gh73962 commented Feb 10, 2025

This PR is based on the solution discussed in the #3208 issue.

@ndyakov
Copy link
Collaborator

ndyakov commented Feb 10, 2025

@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?

@gh73962
Copy link
Author

gh73962 commented Feb 11, 2025

@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.

@ndyakov ndyakov self-requested a review February 21, 2025 12:09
@ndyakov ndyakov changed the title fix: func isEmptyValue support time.Time feat: func isEmptyValue support time.Time Feb 21, 2025
@ndyakov
Copy link
Collaborator

ndyakov commented Feb 26, 2025

@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.

@gh73962
Copy link
Author

gh73962 commented Feb 26, 2025

@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

@ndyakov
Copy link
Collaborator

ndyakov commented Feb 27, 2025

@gh73962 any concrete questions on how to write tests? will you be able to do this on your own?

@gh73962
Copy link
Author

gh73962 commented Feb 28, 2025

In my first commit of the commands_test.go file, the added test covers a scenario that our team frequently encounters.I need you guide, What additional test cases should I include?

@ndyakov ndyakov requested a review from Copilot March 7, 2025 15:09

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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants