pub struct CreateTrigger<'a> {
    pub create_span: Span,
    pub create_options: Vec<CreateOption<'a>>,
    pub trigger_span: Span,
    pub if_not_exists: Option<Span>,
    pub name: Identifier<'a>,
    pub trigger_time: TriggerTime,
    pub trigger_event: TriggerEvent,
    pub on_span: Span,
    pub table: Identifier<'a>,
    pub for_each_row_span: Span,
    pub statement: Box<Statement<'a>>,
}
Expand description

Represent a create trigger statement

let sql = "DROP TRIGGER IF EXISTS `my_trigger`;
DELIMITER $$
CREATE TRIGGER `my_trigger` AFTER DELETE ON `things` FOR EACH ROW BEGIN
    IF OLD.`value` IS NOT NULL THEN
        UPDATE `t2` AS `j`
            SET
            `j`.`total_items` = `total_items` - 1
            WHERE `j`.`id`=OLD.`value` AND NOT `j`.`frozen`;
        END IF;
    INSERT INTO `updated_things` (`thing`) VALUES (OLD.`id`);
END
$$
DELIMITER ;";
let mut stmts = parse_statements(sql, &mut issues, &options);

let create: CreateTrigger = match stmts.pop() {
    Some(Statement::CreateTrigger(c)) => c,
    _ => panic!("We should get an create trigger statement")
};

assert!(create.name.as_str() == "my_trigger");
println!("{:#?}", create.statement)

Fields§

§create_span: Span

Span of “CREATE”

§create_options: Vec<CreateOption<'a>>

Options after “CREATE”

§trigger_span: Span

Span of “TRIGGER”

§if_not_exists: Option<Span>

Span of “IF NOT EXISTS” if specified

§name: Identifier<'a>

Name of the created trigger

§trigger_time: TriggerTime

Should the trigger be fired before or after the event

§trigger_event: TriggerEvent

What event should the trigger be fired on

§on_span: Span

Span of “ON”

§table: Identifier<'a>

Name of table to create the trigger on

§for_each_row_span: Span

Span of “FOR EACH ROW”

§statement: Box<Statement<'a>>

Statement to execute

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Compute byte span of an ast fragment
Compute the minimal span containing both self and other

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.