gluesql_core/executor/alter/
error.rs1use {
2 super::table::Referencing, crate::prelude::DataType, serde::Serialize, std::fmt::Debug,
3 thiserror::Error,
4};
5
6#[derive(Error, Serialize, Debug, PartialEq, Eq)]
7pub enum AlterError {
8 #[error("table already exists: {0}")]
10 TableAlreadyExists(String),
11
12 #[error("function already exists: {0}")]
13 FunctionAlreadyExists(String),
14
15 #[error("function does not exist: {0}")]
16 FunctionNotFound(String),
17
18 #[error("table does not exist: {0}")]
20 TableNotFound(String),
21
22 #[error("CTAS source table does not exist: {0}")]
23 CtasSourceTableNotFound(String),
24
25 #[error("column '{0}' of data type '{1:?}' is unsupported for unique constraint")]
27 UnsupportedDataTypeForUniqueColumn(String, DataType),
28
29 #[error("unsupported index expression")]
31 UnsupportedIndexExpr,
32
33 #[error("unsupported unnamed argument")]
35 UnsupportedUnnamedArg,
36
37 #[error("index expression must reference at least one column")]
38 IndexExprRequiresColumnReference,
39
40 #[error("duplicate column name: {0}")]
41 DuplicateColumnName(String),
42
43 #[error("duplicate arg name: {0}")]
44 DuplicateArgName(String),
45
46 #[error("non-default argument should not follow the default argument")]
47 NonDefaultArgumentFollowsDefaultArgument,
48
49 #[error("foreign table not found: {0}")]
50 ReferencedTableNotFound(String),
51
52 #[error("referenced column not found: {0}")]
53 ReferencedColumnNotFound(String),
54
55 #[error("referencing column not found: {0}")]
56 ReferencingColumnNotFound(String),
57
58 #[error(
59 "referencing column '{referencing_column}' of data type '{referencing_column_type}' does not match referenced column '{referenced_column}' of data type '{referenced_column_type}'"
60 )]
61 ForeignKeyDataTypeMismatch {
62 referencing_column: String,
63 referencing_column_type: DataType,
64 referenced_column: String,
65 referenced_column_type: DataType,
66 },
67
68 #[error(
69 "referenced column '{referenced_table}.{referenced_column}' is not unique, cannot be used as foreign key"
70 )]
71 ReferencingNonPKColumn {
72 referenced_table: String,
73 referenced_column: String,
74 },
75
76 #[error("cannot drop table '{referenced_table_name}' due to referencing tables: '{}'", referencings.iter().map(ToString::to_string).collect::<Vec<_>>().join(", "))]
77 CannotDropTableWithReferencing {
78 referenced_table_name: String,
79 referencings: Vec<Referencing>,
80 },
81
82 #[error("cannot drop column '{}.{}' referenced by '{}'", referencing.foreign_key.referenced_table_name, referencing.foreign_key.referenced_column_name, referencing)]
83 CannotAlterReferencedColumn { referencing: Referencing },
84
85 #[error("cannot drop column '{}.{}' referencing with '{}'", referencing.table_name, referencing.foreign_key.referencing_column_name, referencing)]
86 CannotAlterReferencingColumn { referencing: Referencing },
87}