Default to true for WHEN on DEFINE EVENT statement (#4662)

This commit is contained in:
Dave MacLeod 2024-09-02 19:03:09 +09:00 committed by GitHub
parent 4145f70463
commit 99356dcd49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View file

@ -3,6 +3,7 @@ use reblessive::Stk;
use crate::cnf::EXPERIMENTAL_BEARER_ACCESS;
use crate::sql::access_type::JwtAccessVerify;
use crate::sql::index::HnswParams;
use crate::sql::Value;
use crate::{
sql::{
access_type,
@ -738,6 +739,7 @@ impl Parser<'_> {
let mut res = DefineEventStatement {
name,
what,
when: Value::Bool(true),
if_not_exists,
overwrite,
..Default::default()

View file

@ -344,6 +344,32 @@ async fn define_statement_event() -> Result<(), Error> {
Ok(())
}
// Confirms that a DEFINE EVENT with no WHERE clause will produce WHEN true
#[tokio::test]
async fn define_statement_event_no_when_clause() -> Result<(), Error> {
let sql = "
DEFINE EVENT some_event ON TABLE user THEN {};
INFO FOR TABLE user;
";
let mut t = Test::new(sql).await?;
//
t.skip_ok(1)?;
let val = Value::parse(
"{
events: {
some_event: 'DEFINE EVENT some_event ON user WHEN true THEN { }'
},
fields: {},
indexes: {},
lives: {},
tables: {}
}",
);
t.expect_value(val)?;
//
Ok(())
}
#[tokio::test]
async fn define_statement_event_when_event() -> Result<(), Error> {
let sql = "