reifydb_core/error/diagnostic/
subscription.rs1use reifydb_type::{error::Diagnostic, fragment::Fragment};
5
6pub fn single_statement_required(message: &str) -> Diagnostic {
7 Diagnostic {
8 code: "SUBS_001".to_string(),
9 rql: None,
10 message: message.to_string(),
11 fragment: Fragment::None,
12 label: Some("expected exactly one statement".to_string()),
13 help: Some(
14 "send exactly one CREATE SUBSCRIPTION or DROP SUBSCRIPTION statement per request".to_string()
15 ),
16 column: None,
17 notes: vec![],
18 cause: None,
19 operator_chain: None,
20 }
21}
22
23pub fn invalid_statement(message: &str) -> Diagnostic {
24 Diagnostic {
25 code: "SUBS_002".to_string(),
26 rql: None,
27 message: message.to_string(),
28 fragment: Fragment::None,
29 label: Some("unsupported statement type".to_string()),
30 help: Some("use CREATE SUBSCRIPTION or DROP SUBSCRIPTION".to_string()),
31 column: None,
32 notes: vec![],
33 cause: None,
34 operator_chain: None,
35 }
36}
37
38pub fn subscription_missing_as_clause(fragment: Fragment) -> Diagnostic {
39 Diagnostic {
40 code: "SUBS_003".to_string(),
41 rql: None,
42 message: "CREATE SUBSCRIPTION requires an AS clause".to_string(),
43 fragment,
44 label: Some("missing AS clause".to_string()),
45 help: Some("provide a query with AS { SELECT ... }".to_string()),
46 column: None,
47 notes: vec![],
48 cause: None,
49 operator_chain: None,
50 }
51}