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

Fix timestamp serialization into time.Time, makes zero data <-> zeroTimestamp #375

Merged

Conversation

illia-li
Copy link

@illia-li illia-li commented Dec 12, 2024

Changes:

  1. Unmarshalling zero data into time.Time return time.Time{} before, now returns zeroTimestamp
  2. Marshalling the 0001-1-1T00:00:00Z value of the time.Time return zero data before, now returns a data that is equivalent to the difference between 0001-1-1T00:00:00Z and 1970-1-1T00:00:00Z
  3. Added range matching check for the time.Time on marshalling and relevant tests.

cassandra_test.go Outdated Show resolved Hide resolved
if p == nil {
*v = time.Time{}
} else {
*v = zeroTimestamp.UTC()
Copy link
Collaborator

Choose a reason for hiding this comment

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

it should be in UTC already

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

serialization/timestamp/unmarshal_utils.go Outdated Show resolved Hide resolved
@illia-li illia-li force-pushed the il/fix/marshal/timestamp_zero_nil_time branch from 9b9fb7b to bf0f663 Compare December 13, 2024 15:29
Changes:
1) Unmarshalling `zero data` into `time.Time` return `time.Time{}` before, now returns `zeroTimestamp`
2) Marshalling the `0001-1-1T00:00:00Z` value of the `time.Time` return `zero data` before, now returns a data that is equivalent to the difference between `0001-1-1T00:00:00Z` and `1970-1-1T00:00:00Z`
3) Tests fixed
@illia-li illia-li changed the title Fix timestamp fixed zero data serialization for time.Time fix timestamp serialization into time.Time, makes zero data <-> zeroTimestamp Dec 13, 2024
@illia-li illia-li force-pushed the il/fix/marshal/timestamp_zero_nil_time branch from bf0f663 to 5f6e337 Compare December 13, 2024 16:18
@illia-li illia-li changed the title fix timestamp serialization into time.Time, makes zero data <-> zeroTimestamp Fix timestamp serialization into time.Time, makes zero data <-> zeroTimestamp Dec 13, 2024
@dkropachev dkropachev merged commit 0ca791b into scylladb:master Dec 13, 2024
2 checks passed
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.

2 participants