pub struct Query(/* private fields */);
Expand description
A SQL query.
Implementations§
Source§impl Query
impl Query
pub fn new(sql: String) -> Self
pub fn sql(&self) -> &str
Sourcepub fn append(&mut self, other: Self) -> TernResult<()>
pub fn append(&mut self, other: Self) -> TernResult<()>
Add another query to the end of this one.
Sourcepub fn split_statements(&self) -> TernResult<Vec<String>>
pub fn split_statements(&self) -> TernResult<Vec<String>>
Split a query comprised of multiple statements.
For queries having no_tx = true
, a migration comprised of multiple,
separate SQL statements needs to be broken up so that the statements can
run sequentially. Otherwise, many backends will run the collection of
statements in a transaction automatically, which breaches the no_tx
contract.
Warning: This is sensitive to the particular character sequence for
writing comments. Only --
and C-style /* ... */
are treated
correctly because this is valid comment syntax in any of the supported
backends. A line starting with #
, for instance, will not be treated as
a comment, and so only in MySQL where that does denote a comment, the
function may not separate multiple statements correctly, possibly leading
to syntax errors during query execution.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnwindSafe for Query
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