From 3cbb5eed780b8620a35dd51328ddbaa6a4521922 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 25 Oct 2022 06:06:02 -0700 Subject: [PATCH] Allow datetimes as an `id` parameter in the WebSocket RPC message --- lib/src/sql/value/value.rs | 4 ++++ src/net/rpc.rs | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index 4f0805d4..19795e90 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -589,6 +589,10 @@ impl Value { matches!(self, Value::Number(v) if v.is_positive()) } + pub fn is_datetime(&self) -> bool { + matches!(self, Value::Datetime(_)) + } + pub fn is_type_record(&self, types: &[Table]) -> bool { match self { Value::Thing(v) => types.iter().any(|tb| tb.0 == v.tb), diff --git a/src/net/rpc.rs b/src/net/rpc.rs index 33ddc581..717e46f1 100644 --- a/src/net/rpc.rs +++ b/src/net/rpc.rs @@ -146,10 +146,13 @@ impl Rpc { }; // Fetch the 'id' argument let id = match req.pick(&*ID) { - v if v.is_uuid() || v.is_strand() || v.is_number() || v.is_none() || v.is_null() => { - Some(v) - } - _ => return res::failure(None, Failure::INVALID_REQUEST).send(chn).await, + v if v.is_none() => None, + v if v.is_null() => Some(v), + v if v.is_uuid() => Some(v), + v if v.is_number() => Some(v), + v if v.is_strand() => Some(v), + v if v.is_datetime() => Some(v), + _ => return res::failure(None, Failure::INVALID_REQUEST).send(out, chn).await, }; // Fetch the 'method' argument let method = match req.pick(&*METHOD) {