From 7448cd1305931c3be2694b5155a2068d05bf6e74 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 13 Apr 2023 20:31:22 +0100 Subject: [PATCH] Ensure custom functions can write data Closes #1808 --- lib/src/sql/function.rs | 4 ++++ lib/src/sql/value/value.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/sql/function.rs b/lib/src/sql/function.rs index 177d0d29..fe237d35 100644 --- a/lib/src/sql/function.rs +++ b/lib/src/sql/function.rs @@ -86,6 +86,10 @@ impl Function { _ => unreachable!(), } } + /// Check if this function is a custom function + pub fn is_custom(&self) -> bool { + matches!(self, Self::Custom(_, _)) + } /// Check if this function is a rolling function pub fn is_rolling(&self) -> bool { match self { diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index 1af4d7cb..46e5cece 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -1417,7 +1417,7 @@ impl Value { Value::Block(v) => v.writeable(), Value::Array(v) => v.iter().any(Value::writeable), Value::Object(v) => v.iter().any(|(_, v)| v.writeable()), - Value::Function(v) => v.args().iter().any(Value::writeable), + Value::Function(v) => v.is_custom() || v.args().iter().any(Value::writeable), Value::Subquery(v) => v.writeable(), Value::Expression(v) => v.l.writeable() || v.r.writeable(), _ => false,