pub struct CreateView<'a> {
    pub create_span: Span,
    pub create_options: Vec<CreateOption<'a>>,
    pub view_span: Span,
    pub if_not_exists: Option<Span>,
    pub name: Identifier<'a>,
    pub as_span: Span,
    pub select: Select<'a>,
}
Expand description

Represent a create view statement

let sql = "CREATE ALGORITHM=UNDEFINED DEFINER=`phpmyadmin`@`localhost` SQL SECURITY DEFINER
   VIEW `v1`
   AS SELECT
        `t1`.`id` AS `id`,
        `t1`.`c1` AS `c1`,
        (SELECT `t2`.`c2` FROM `t2` WHERE `t2`.`id` = `t1`.`c3`) AS `c2`
        FROM `t1` WHERE `t1`.`deleted` IS NULL;";
let mut stmts = parse_statements(sql, &mut issues, &options);

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

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

Fields

create_span: Span

Span of “CREATE”

create_options: Vec<CreateOption<'a>>

Options after “CREATE”

view_span: Span

Span of “VIEW”

if_not_exists: Option<Span>

Span of “IF NOT EXISTS” if specified

name: Identifier<'a>

Name of the created view

as_span: Span

Span of “AS”

select: Select<'a>

The select statement following “AS”

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.