Struct sql_parse::Delete

source ·
pub struct Delete<'a> {
    pub delete_span: Span,
    pub flags: Vec<DeleteFlag>,
    pub from_span: Span,
    pub tables: Vec<Vec<Identifier<'a>>>,
    pub using: Vec<TableReference<'a>>,
    pub where_: Option<(Expression<'a>, Span)>,
}
Expand description

Represent a delete statement

let sql = "DELETE FROM t1 WHERE c1 IN (SELECT b.c1 FROM t1 b WHERE b.c2=0);";

let mut stmts = parse_statements(sql, &mut issues, &options);

let delete: Delete = match stmts.pop() {
    Some(Statement::Delete(d)) => d,
    _ => panic!("We should get a delete statement")
};

assert!(delete.tables[0][0].as_str() == "t1");
println!("{:#?}", delete.where_);

let sql = "DELETE `t1` FROM `t1` LEFT JOIN `t2` ON `t1`.`t2_id`=`t2`.`id` WHERE `t2`.`key`='my_key';";

let mut stmts = parse_statements(sql, &mut issues, &options);

Fields§

§delete_span: Span

Span of “DELETE”

§flags: Vec<DeleteFlag>

Flags following “DELETE”

§from_span: Span

Span of “FROM”

§tables: Vec<Vec<Identifier<'a>>>

Tables to do deletes on

§using: Vec<TableReference<'a>>

Table to use in where clause in multi table delete

§where_: Option<(Expression<'a>, Span)>

Where expression and Span of “WHERE” if specified

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.