Struct Select

Source
pub struct Select { /* private fields */ }
Expand description

Represents the creation of a SELECT with specified table and options.

Implementations§

Source§

impl Select

Source

pub fn new(table: &str) -> Self

Creates a new Select instance with the specified table name.

§Example
use lumus_sql_builder::sqlite::Select;
let select = Select::new("users").columns("name, age").build().unwrap();
assert_eq!(select, "SELECT name, age FROM users;")
Source

pub fn from(query: &str) -> Result<Select, SqlBuilderError>

Creates a new Select instance from a SQL query string. The query string should be in the format “SELECT * FROM table_name [WHERE condition] [GROUP BY column] [ORDER BY column] [LIMIT limit] [OFFSET offset]”.

§Example
use lumus_sql_builder::sqlite::Select;
let query = "SELECT * FROM users WHERE age > 18 GROUP BY city ORDER BY name LIMIT 10 OFFSET 0";
Select::from(query);
Source

pub fn distinct(&mut self) -> &mut Self

Specifies that the select statement should return distinct rows.

Source

pub fn columns(&mut self, columns: &str) -> &mut Self

Specifies the columns to be selected in the query.

Source

pub fn group(&mut self, group: &str) -> &mut Self

Specifies the grouping for the query results.

Source

pub fn order(&mut self, order: &str) -> &mut Self

Specifies the ordering for the query results.

Source

pub fn condition(&mut self, condition: String) -> &mut Self

Specifies where for Select.

Source

pub fn limit(&mut self, limit: u32) -> &mut Self

Specifies the maximum number of rows to be returned by the query.

Source

pub fn offset(&mut self, offset: u32) -> &mut Self

Specifies the offset for the query results.

Source

pub fn join(&mut self, join: String) -> &mut Self

Specifies a join.

Source

pub fn build(&self) -> Result<String, SqlBuilderError>

Builds and returns the SQL statement for the select query.

Trait Implementations§

Source§

impl Debug for Select

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Select

§

impl RefUnwindSafe for Select

§

impl Send for Select

§

impl Sync for Select

§

impl Unpin for Select

§

impl UnwindSafe for Select

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

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>,

Source§

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.