From 374644b9bd142aa025c7c396e8d37d2934b57654 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 26 Jan 2022 13:58:39 +0000 Subject: [PATCH] Improve type::thing() function When running type::thing() with a record id the function now returns the correct record. For example type::thing("test", test:id) now returns the record test:id. --- src/fnc/type.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/fnc/type.rs b/src/fnc/type.rs index e7444192..e540f9d5 100644 --- a/src/fnc/type.rs +++ b/src/fnc/type.rs @@ -102,8 +102,16 @@ pub fn table(_: &Runtime, mut args: Vec) -> Result { } pub fn thing(_: &Runtime, mut args: Vec) -> Result { - Ok(Value::Thing(Thing { - tb: args.remove(0).as_strand().value, - id: args.remove(0).as_strand().value, - })) + match args.remove(0) { + tb => match args.remove(0) { + Value::Thing(id) => Ok(Value::Thing(Thing { + tb: tb.as_strand().value, + id: id.id, + })), + id => Ok(Value::Thing(Thing { + tb: tb.as_strand().value, + id: id.as_strand().value, + })), + }, + } }