Skip to content

use Uuid:::from_u128 for uuid_to_string #1362

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

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/serializers/type_serializers/uuid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::borrow::Cow;

use pyo3::prelude::*;
use pyo3::types::PyDict;
use pyo3::{intern, prelude::*};
use uuid::Uuid;

use crate::definitions::DefinitionsBuilder;

Expand All @@ -11,7 +12,10 @@ use super::{
};

pub(crate) fn uuid_to_string(py_uuid: &Bound<'_, PyAny>) -> PyResult<String> {
Ok(py_uuid.str()?.to_string())
let py = py_uuid.py();
let uuid_int_val: u128 = py_uuid.getattr(intern!(py, "int"))?.extract()?;
let uuid = Uuid::from_u128(uuid_int_val);
Ok(uuid.to_string())
}

#[derive(Debug, Clone)]
Expand Down