Skip to content

Commit a622232

Browse files
committed
sql_parser: create statements ASTs (2)
1 parent ada575e commit a622232

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

src/ast/create.rs

+53-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{
2-
ColumnDefinition, ConflictClause, Expression, ForeignKeyClause, Identifier, IndexedColumn,
3-
SelectStatement,
2+
ColumnDefinition, ConflictClause, DeleteStatement, Expression, ForeignKeyClause, Identifier,
3+
IndexedColumn, InsertStatement, SelectStatement, UpdateStatement,
44
};
55

66
/// An AST for [CREATE VIRTUAL TABLE](https://www.sqlite.org/lang_createvtab.html) SQL statement.
@@ -100,4 +100,54 @@ pub enum TableOption {
100100

101101
/// An AST for [CREATE TRIGGER](https://www.sqlite.org/lang_createtrigger.html) SQL statement.
102102
#[derive(Debug, PartialEq)]
103-
pub struct CreateTriggerStatement {}
103+
pub struct CreateTriggerStatement {
104+
pub temporary: bool,
105+
106+
pub if_not_exists: bool,
107+
108+
pub trigger_name: Identifier,
109+
110+
pub trigger_pre_condition: Option<TriggerPreCondition>,
111+
112+
pub trigger_event: TriggerEvent,
113+
114+
pub for_each_row: bool,
115+
116+
pub when_clause: Option<Expression>,
117+
118+
pub trigger_statements: Vec<TriggerStatement>,
119+
}
120+
121+
#[derive(Debug, PartialEq)]
122+
pub enum TriggerPreCondition {
123+
Before,
124+
125+
After,
126+
127+
InsteadOf,
128+
}
129+
130+
#[derive(Debug, PartialEq)]
131+
pub struct TriggerEvent {
132+
pub event_type: TriggerEventType,
133+
134+
pub table_name: Identifier,
135+
}
136+
137+
#[derive(Debug, PartialEq)]
138+
pub enum TriggerEventType {
139+
Delete,
140+
Insert,
141+
Update(Option<Vec<Identifier>>),
142+
}
143+
144+
#[derive(Debug, PartialEq)]
145+
pub enum TriggerStatement {
146+
Update(UpdateStatement),
147+
148+
Insert(InsertStatement),
149+
150+
Delete(DeleteStatement),
151+
152+
Select(SelectStatement),
153+
}

0 commit comments

Comments
 (0)