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§

source§

impl<'a> Clone for Delete<'a>

source§

fn clone(&self) -> Delete<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Delete<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Spanned for Delete<'a>

source§

fn span(&self) -> Span

Compute byte span of an ast fragment
source§

fn join_span(&self, other: &impl OptSpanned) -> Span

Compute the minimal span containing both self and other

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Delete<'a>

§

impl<'a> Send for Delete<'a>

§

impl<'a> Sync for Delete<'a>

§

impl<'a> Unpin for Delete<'a>

§

impl<'a> UnwindSafe for Delete<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.