pub struct QueryColumns { /* private fields */ }
Expand description
Represents a collection of query columns.
§Example
use safety_postgres::access::sql_base::QueryColumns;
let mut query_columns = QueryColumns::new(false);
query_columns.add_column("schema_name", "table_name", "column_name").unwrap();
let query_text = query_columns.get_query_text();
assert_eq!(query_text, "SELECT schema_name.table_name.column_name FROM main_table_name");
Implementations§
Source§impl QueryColumns
impl QueryColumns
Sourcepub fn new(all_columns: bool) -> Self
pub fn new(all_columns: bool) -> Self
Creates a new instance of QueryColumns
struct.
§Arguments
all_columns
- A boolean value indicating whether all columns should be selected.
Sourcepub fn add_column(
&mut self,
schema_name: &str,
table_name: &str,
column: &str,
) -> Result<&mut Self, QueryColumnError>
pub fn add_column( &mut self, schema_name: &str, table_name: &str, column: &str, ) -> Result<&mut Self, QueryColumnError>
Adds a query selected column to the query.
§Arguments
schema_name
- The name of the schema (input “” if there is no schema name or in the same table).table_name
- The name of the table (input “” if there is no table name or in the same table).column
- The name of the column.
§Returns
Returns a mutable reference to Self
(the query builder) on success, or a QueryColumnError
on failure.
§Errors
An error is returned if:
- The
all_columns
flag is set to true, indicating that all columns will be queried, so setting a specific column is not allowed. - The
schema_name
,table_name
, orcolumn
is an invalid string.
§Example
use safety_postgres::access::sql_base::QueryColumns;
let mut query_columns = QueryColumns::new(false);
query_columns.add_column("", "", "id").unwrap().add_column("", "", "username").unwrap();
Sourcepub fn get_query_text(&self) -> String
pub fn get_query_text(&self) -> String
Trait Implementations§
Source§impl Clone for QueryColumns
impl Clone for QueryColumns
Source§fn clone(&self) -> QueryColumns
fn clone(&self) -> QueryColumns
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for QueryColumns
impl RefUnwindSafe for QueryColumns
impl Send for QueryColumns
impl Sync for QueryColumns
impl Unpin for QueryColumns
impl UnwindSafe for QueryColumns
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
Mutably borrows from an owned value. Read more