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

fixing duration class and adding a testing file for it #175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maxwellflitton
Copy link
Contributor

Thank you for submitting this pull request! We appreciate you spending the time to work on these changes.

What is the motivation?

offering a fix to the Duration field not working with cbor as highlighted in this issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

What does this change do?

Gets Duration working with Cbor

What is your testing strategy?

I've written a testing file to test how the Duration data type processes data and how it interacts with the SurrealDB database.

Is this related to any issues?

issue

Have you read the Contributing Guidelines?

@@ -65,7 +62,7 @@ def default_encoder(encoder, obj):
tagged = CBORTag(constants.TAG_BOUND_EXCLUDED, obj.value)

elif isinstance(obj, Duration):
tagged = CBORTag(constants.TAG_DURATION, obj.get_seconds_and_nano())
tagged = CBORTag(constants.TAG_DURATION, obj.to_string())
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this not be constants.TAG_DURATION_COMPACT since obj.get_seconds_and_nano() returns the correct format for that?

@@ -116,6 +113,8 @@ def tag_decoder(decoder, tag, shareable_index=None):
return Range(tag.value[0], tag.value[1])

elif tag.tag == constants.TAG_DURATION_COMPACT:
if len(tag.value) == 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be the decoding for constants.TAG_DURATION see:
https://surrealdb.com/docs/surrealdb/integration/cbor#tag-14

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