From 6ede630d4112a75099c638b29f572af1b347e308 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 26 Mar 2023 23:54:57 +0100 Subject: [PATCH] Allow unbounded / untyped record type constraints --- lib/src/sql/kind.rs | 4 ++-- lib/src/sql/value/value.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/sql/kind.rs b/lib/src/sql/kind.rs index 0131e459..2b467638 100644 --- a/lib/src/sql/kind.rs +++ b/lib/src/sql/kind.rs @@ -7,7 +7,7 @@ use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::char; use nom::combinator::map; -use nom::multi::separated_list1; +use nom::multi::{separated_list0, separated_list1}; use serde::{Deserialize, Serialize}; use std::fmt::{self, Display, Formatter}; @@ -76,7 +76,7 @@ fn record(i: &str) -> IResult<&str, Vec> { let (i, _) = tag("record")(i)?; let (i, _) = mightbespace(i)?; let (i, _) = char('(')(i)?; - let (i, v) = separated_list1(commas, table)(i)?; + let (i, v) = separated_list0(commas, table)(i)?; let (i, _) = char(')')(i)?; Ok((i, v)) } diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index fe8d665c..f9221420 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -762,7 +762,7 @@ impl Value { /// Check if this Value is a Thing of a specific type pub fn is_type_record(&self, types: &[Table]) -> bool { match self { - Value::Thing(v) => types.iter().any(|tb| tb.0 == v.tb), + Value::Thing(v) => types.is_empty() || types.iter().any(|tb| tb.0 == v.tb), _ => false, } }