reifydb_core/error/diagnostic/
sequence.rs1use reifydb_type::{
5 error::{Diagnostic, util::value_max},
6 fragment::Fragment,
7 value::r#type::Type,
8};
9
10pub fn sequence_exhausted(value: Type) -> Diagnostic {
11 Diagnostic {
12 code: "SEQUENCE_001".to_string(),
13 statement: None,
14 message: format!("sequence generator of type `{}` is exhausted", value),
15 fragment: Fragment::None,
16 label: Some("no more values can be generated".to_string()),
17 help: Some(format!("maximum value for `{}` is `{}`", value, value_max(value.clone()))),
18 column: None,
19 notes: vec![],
20 cause: None,
21 operator_chain: None,
22 }
23}
24
25pub fn can_not_alter_not_auto_increment(fragment: Fragment) -> Diagnostic {
26 Diagnostic {
27 code: "SEQUENCE_002".to_string(),
28 statement: None,
29 message: format!(
30 "cannot alter sequence for column `{}` which does not have AUTO INCREMENT",
31 fragment.text()
32 ),
33 fragment,
34 label: Some("column does not have AUTO INCREMENT".to_string()),
35 help: Some("only columns with AUTO INCREMENT can have their sequences altered".to_string()),
36 column: None,
37 notes: vec![],
38 cause: None,
39 operator_chain: None,
40 }
41}