Allow empty params object from text-based WebSocket clients

Closes 
This commit is contained in:
Tobie Morgan Hitchcock 2023-01-20 00:54:09 +00:00
parent 6785c65b60
commit 9282feac1f
2 changed files with 5 additions and 1 deletions
lib/src/sql/value
src/net

View file

@ -601,6 +601,10 @@ impl Value {
// Simple value detection
// -----------------------------------
pub fn is_none_or_null(&self) -> bool {
matches!(self, Value::None | Value::Null)
}
pub fn is_none(&self) -> bool {
matches!(self, Value::None)
}

View file

@ -290,7 +290,7 @@ impl Rpc {
},
// Run a full SurrealQL query against the database
"query" => match params.needs_one_or_two() {
Ok((Value::Strand(s), o)) if o.is_none() => {
Ok((Value::Strand(s), o)) if o.is_none_or_null() => {
return match rpc.read().await.query(s).await {
Ok(v) => res::success(id, v).send(out, chn).await,
Err(e) => {