pub struct Statement { /* private fields */ }Expand description
A schema change, ready to render for any database.
Implementations§
Source§impl Statement
impl Statement
Sourcepub fn only(self, dialect: Dialect) -> Self
pub fn only(self, dialect: Dialect) -> Self
Limits the statement to one database family, as a Laravel migration wraps a call in
if (DB::getDriverName() === 'mysql') { ... }. On that family the statement renders as
usual; on the others it renders to an empty list, and nothing runs. It works on every
statement: create, table, drop and statement.
A statement for another family is not rendered at all, so an invalid name in it is not
reported there either. Calling only twice keeps the last call.
Sourcepub fn to_sql(&self, driver: Driver) -> Vec<String>
pub fn to_sql(&self, driver: Driver) -> Vec<String>
Renders the statement for driver: one SQL statement per element, to run in order.
§Panics
Panics when a name is invalid or a default has no SQL literal. Use
try_to_sql to get the error instead.
Sourcepub fn try_to_sql(&self, driver: Driver) -> Result<Vec<String>, Error>
pub fn try_to_sql(&self, driver: Driver) -> Result<Vec<String>, Error>
Renders the statement for driver, or the error for an invalid name. A table, column or
index column name must not be empty or contain a backtick or a double quote, the rule of
the query builder. An operation the database cannot do, or an alter-only command such as
rename_column inside create, is Error::Unsupported. A raw statement is never
an error, and a statement limited by only to another family renders as an
empty list.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Statement
impl Freeze for Statement
impl Move for Statement
impl RefUnwindSafe for Statement
impl Send for Statement
impl Sync for Statement
impl Unpin for Statement
impl UnsafeUnpin for Statement
impl UnwindSafe for Statement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more