Struct arel::sql::Sql

source ·
pub struct Sql {
    pub raw_value: String,
    pub bind_indexs: Vec<usize>,
    pub bind_values: Vec<Value>,
}

Fields§

§raw_value: String§bind_indexs: Vec<usize>§bind_values: Vec<Value>

Implementations§

source§

impl Sql

source

pub fn new<T: ToString>(value: T) -> Self

source

pub fn push_str<T: AsRef<str>>(&mut self, raw_str: T) -> &mut Self

source

pub fn push_strs<T: AsRef<str>>( &mut self, raw_strs: Vec<T>, separated_str: &str ) -> &mut Self

source

pub fn push_bind<V: Into<Value>>(&mut self, bind_value: V) -> &mut Self

source

pub fn push_binds<V: Into<Value>>( &mut self, bind_values: Vec<V>, separated_str: &str ) -> &mut Self

source

pub fn push_str_with_bind<T: AsRef<str>, V: Into<Value>>( &mut self, raw_str: T, bind_value: V ) -> &mut Self

source

pub fn push_sql(&mut self, sql: Sql) -> &mut Self

source

pub fn push_sqls(&mut self, sqls: Vec<Sql>, separated_str: &str) -> &mut Self

source

pub fn to_sql_string(&self) -> Result<String>

source§

impl Sql

source

pub fn range_sql<K: AsRef<str>, V: ToString, R: RangeBounds<V>>( key: K, range: R ) -> Option<Sql>

Examples
let sql = arel::Sql::range_sql("age", ..18).unwrap();
assert_eq!(sql.to_sql_string().unwrap(), r#"age < 18"#);

let sql = arel::Sql::range_sql("age", ..=18).unwrap();
assert_eq!(sql.to_sql_string().unwrap(), r#"age <= 18"#);

let sql = arel::Sql::range_sql("age", 18..20).unwrap();
assert_eq!(sql.to_sql_string().unwrap(), r#"age >= 18 AND age < 20"#);

let sql = arel::Sql::range_sql("age", 18..=20).unwrap();
assert_eq!(sql.to_sql_string().unwrap(), r#"age BETWEEN 18 AND 20"#);

let sql = arel::Sql::range_sql("age", (std::ops::Bound::Excluded(18), std::ops::Bound::Included(20))).unwrap();
assert_eq!(sql.to_sql_string().unwrap(), r#"age > 18 AND age <= 20"#);

let sql = arel::Sql::range_sql("age", 18..).unwrap();
assert_eq!(sql.to_sql_string().unwrap(), r#"age >= 18"#);
source§

impl Sql

source

pub async fn exec<'a, E>(&self, executor: E) -> Result<DatabaseQueryResult>
where E: Executor<'a, Database = Database>,

source

pub async fn fetch_one_with_exec<'a, E>( &self, executor: E ) -> Result<DatabaseRow>
where E: Executor<'a, Database = Database>,

source

pub async fn fetch_one_as_with_exec<'a, T, E>(&self, executor: E) -> Result<T>
where for<'b> T: Send + Unpin + FromRow<'b, DatabaseRow>, E: Executor<'a, Database = Database>,

source

pub async fn fetch_one_optional_as_with_exec<'a, T, E>( &self, executor: E ) -> Result<Option<T>>
where for<'b> T: Send + Unpin + FromRow<'b, DatabaseRow>, E: Executor<'a, Database = Database>,

Trait Implementations§

source§

impl Clone for Sql

source§

fn clone(&self) -> Sql

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 Debug for Sql

source§

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

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

impl Default for Sql

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: ToString> From<T> for Sql

source§

fn from(value: T) -> Self

Converts to this type from the input type.
source§

impl<'a> TryFrom<&Sql> for QueryBuilder<'a>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(sql: &Sql) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<Sql> for QueryBuilder<'a>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(sql: Sql) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Sql> for String

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(sql: Sql) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl RefUnwindSafe for Sql

§

impl Send for Sql

§

impl Sync for Sql

§

impl Unpin for Sql

§

impl UnwindSafe for Sql

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more