[−][src]Struct toql_core::query::Query
A Query contains fields and wildcards. It can be turned into SQL using the SQL Builder.
To build a big query simple add fields and wildcards with and resp. or function.
Watch out: Logical AND has precendence over OR. So a OR b AND c
is the same as a OR (b AND c)
.
Avoid to restrict your query with a permission field WITHOUT parenthesize the incoming query.
Malicious users will circumvent your permission filter with a simple OR clause at the beginning.
Consider this: (*, id nen); id, permission ne ""
vs ((*, id nen); id), permission ne ""
.
To parenthesize a query use the parenthesize() method.
let q1 = Query::new().and(Field("b").eq(3)).and(Field("c").eq(2)); let q2 = Query::new().and(Field("a").eq(1)).or(q1.parens()); assert_eq!("a eq 1; (b eq 3, c eq 2)", q2.to_string())
Fields
distinct: bool
Select DISTINCT
roles: BTreeSet<String>
Roles a query has to access fields. See MapperOption for explanation.
Methods
impl Query
[src]
pub fn new() -> Self
[src]
Create a new empty query.
pub fn wildcard() -> Self
[src]
Create a new query that select all top fields.
pub fn double_wildcard() -> Self
[src]
Create a new query that select all top fields and all dependend fields. This is the best :)
pub fn parenthesize(self) -> Self
[src]
Wrap query with parentheses.
pub fn and<T>(self, query: T) -> Self where
T: Into<Query>,
[src]
T: Into<Query>,
Concatenate field or query with AND.
pub fn or<T>(self, query: T) -> Self where
T: Into<Query>,
[src]
T: Into<Query>,
Concatenate field or query with OR.
Trait Implementations
impl Clone for Query
[src]
fn clone(&self) -> Query
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<Field> for Query
[src]
impl From<Wildcard> for Query
[src]
impl<'_> From<&'_ str> for Query
[src]
impl Debug for Query
[src]
impl Display for Query
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,