gluesql_core/translate/
error.rs

1use {serde::Serialize, std::fmt::Debug, thiserror::Error};
2
3#[derive(Error, Serialize, Debug, PartialEq, Eq)]
4pub enum TranslateError {
5    #[error("unimplemented - select on two or more than tables are not supported")]
6    TooManyTables,
7
8    #[error("unimplemented - SELECT DISTINCT ON is not supported")]
9    SelectDistinctOnNotSupported,
10
11    #[error("unimplemented - composite index is not supported")]
12    CompositeIndexNotSupported,
13
14    #[error("unimplemented - join on update not supported")]
15    JoinOnUpdateNotSupported,
16
17    #[error("unimplemented - compound identifier on update not supported: {0}")]
18    CompoundIdentOnUpdateNotSupported(String),
19
20    #[error("unimplemented - tuple assigment on update is not supported: {0}")]
21    TupleAssignmentOnUpdateNotSupported(String),
22
23    #[error("too many params in drop index")]
24    TooManyParamsInDropIndex,
25
26    #[error("invalid params in drop index, expected: table_name.index_name")]
27    InvalidParamsInDropIndex,
28
29    #[error("function args.length not matching: {name}, expected: {expected}, found: {found}")]
30    FunctionArgsLengthNotMatching {
31        name: String,
32        expected: usize,
33        found: usize,
34    },
35
36    #[error("function {name} requires at least {expected_minimum} argument(s), found: {found}")]
37    FunctionArgsLengthNotMatchingMin {
38        name: String,
39        expected_minimum: usize,
40        found: usize,
41    },
42
43    #[error(
44        "function args.length not matching: {name}, expected: {expected_minimum} ~ {expected_maximum}, found: {found}"
45    )]
46    FunctionArgsLengthNotWithinRange {
47        name: String,
48        expected_minimum: usize,
49        expected_maximum: usize,
50        found: usize,
51    },
52
53    #[error("named function arg is not supported")]
54    NamedFunctionArgNotSupported,
55
56    #[error("unnamed function arg is not supported")]
57    UnNamedFunctionArgNotSupported,
58
59    #[error("subquery function arg is not supported")]
60    UnreachableSubqueryFunctionArgNotSupported,
61
62    #[error("INSERT INTO {0} DEFAULT VALUES is not supported")]
63    DefaultValuesOnInsertNotSupported(String),
64
65    #[error("empty function body is not supported")]
66    UnsupportedEmptyFunctionBody,
67
68    #[error("unsupported unnamed index")]
69    UnsupportedUnnamedIndex,
70
71    #[error(
72        "unsupported trim chars: expected: `TRIM((BOTH | LEADING | TRAILING) <text> FROM <expr>)`, got: `TRIM(<expr> [<chars>, ..])` syntax"
73    )]
74    UnsupportedTrimChars,
75
76    #[error("unsupported CAST format: {0}")]
77    UnsupportedCastFormat(String),
78
79    #[error("TRY_CAST(..) is not supported")]
80    TryCastNotSupported,
81
82    #[error("SAFE_CAST(..) is not supported")]
83    SafeCastNotSupported,
84
85    #[error(
86        "unsupported multiple alter table operations, expected: `ALTER TABLE <table> <operation>`, got: `ALTER TABLE <table> <operation>, <operation>, ..`"
87    )]
88    UnsupportedMultipleAlterTableOperations,
89
90    #[error("unreachable empty alter table operation")]
91    UnreachableEmptyAlterTableOperation,
92
93    #[error("unsupported `GROUP BY (ALL)`")]
94    UnsupportedGroupByAll,
95
96    #[error("wildcard function arg is not accepted")]
97    WildcardFunctionArgNotAccepted,
98
99    #[error("qualified wildcard is not supported - COUNT({0})")]
100    QualifiedWildcardInCountNotSupported(String),
101
102    #[error("order by - NULLS (FIRST | LAST) is not supported")]
103    OrderByNullsFirstOrLastNotSupported,
104
105    #[error("unsupported SHOW VARIABLE keyword: {0}")]
106    UnsupportedShowVariableKeyword(String),
107
108    #[error("unsupported SHOW VARIABLE statement: {0}")]
109    UnsupportedShowVariableStatement(String),
110
111    #[error("unsupported statement: {0}")]
112    UnsupportedStatement(String),
113
114    #[error("unsupported expr: {0}")]
115    UnsupportedExpr(String),
116
117    #[error("unsupported data type: {0}")]
118    UnsupportedDataType(String),
119
120    #[error("unsupported datetime field: {0}")]
121    UnsupportedDateTimeField(String),
122
123    #[error("unsupported ast literal: {0}")]
124    UnsupportedAstLiteral(String),
125
126    #[error("unreachable unary operator: {0}")]
127    UnreachableUnaryOperator(String),
128
129    #[error("unreachable empty ident")]
130    UnreachableEmptyIdent,
131
132    #[error("unsupported binary operator: {0}")]
133    UnsupportedBinaryOperator(String),
134
135    #[error("unsupported query set expr: {0}")]
136    UnsupportedQuerySetExpr(String),
137
138    #[error("unsupported query table factor: {0}")]
139    UnsupportedQueryTableFactor(String),
140
141    #[error("unsupported join constraint: {0}")]
142    UnsupportedJoinConstraint(String),
143
144    #[error("unsupported join operator: {0}")]
145    UnsupportedJoinOperator(String),
146
147    #[error("unsupported column option: {0}")]
148    UnsupportedColumnOption(String),
149
150    #[error("unsupported alter table operation: {0}")]
151    UnsupportedAlterTableOperation(String),
152
153    #[error("unsupported table factor: {0}")]
154    UnsupportedTableFactor(String),
155
156    #[error("Every derived table must have its own alias")]
157    LackOfAlias,
158
159    #[error("Series should have size")]
160    LackOfArgs,
161
162    #[error("unreachable empty object")]
163    UnreachableEmptyObject,
164
165    #[error("unreachable empty table")]
166    UnreachableEmptyTable,
167
168    #[error("unreachable - FROM cannot be ommitted in DELETE statement")]
169    UnreachableOmittingFromInDelete,
170
171    #[error("unimplemented - compound object is supported: {0}")]
172    CompoundObjectNotSupported(String),
173
174    #[error("cannot create index with reserved name: {0}")]
175    ReservedIndexName(String),
176
177    #[error("cannot drop primary index")]
178    CannotDropPrimary,
179
180    #[error("unreachable - empty columns")]
181    UnreachableForeignKeyColumns(String),
182
183    #[error("unsupported constraint: {0}")]
184    UnsupportedConstraint(String),
185}