From d4f1c28a4a0b6bda06f05b113d510f4af58e9bce Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 23 Nov 2022 08:58:56 +0000 Subject: [PATCH] Add conversion functionality from Thing to ID Closes #1454 --- lib/src/sql/id.rs | 7 +++++++ lib/src/sql/value/value.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/sql/id.rs b/lib/src/sql/id.rs index 0f6436c8..c14fe580 100644 --- a/lib/src/sql/id.rs +++ b/lib/src/sql/id.rs @@ -10,6 +10,7 @@ use crate::sql::ident::ident_raw; use crate::sql::number::integer; use crate::sql::object::{object, Object}; use crate::sql::strand::Strand; +use crate::sql::thing::Thing; use crate::sql::uuid::Uuid; use crate::sql::value::Value; use nanoid::nanoid; @@ -86,6 +87,12 @@ impl From> for Id { } } +impl From for Id { + fn from(v: Thing) -> Self { + v.id + } +} + impl Id { /// Generate a new random ID pub fn rand() -> Self { diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index 110ea3ed..eabcb613 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -465,7 +465,7 @@ impl From for Value { fn from(v: Id) -> Self { match v { Id::Number(v) => v.into(), - Id::String(v) => Strand::from(v).into(), + Id::String(v) => v.into(), Id::Object(v) => v.into(), Id::Array(v) => v.into(), }