Struct toql_core::table_mapper::TableMapper
source · [−]pub struct TableMapper {
pub table_name: String,
pub canonical_table_alias: String,
/* private fields */
}
Expand description
Translates Toql fields into columns or SQL expressions.
It’s needed by the SQL Builder to turn a Query into a SQL Builder Result.
The Toql derive generates the TabeMapper instructions and puts them into the Mapped trait.
Every ToqlApi function quickly checks,
if TableMapperRegistry
contains the TableMapper
. If the mapper is missing it will call TreeMap to map an entity and all its dependencies.
TreeMap itself uses from_mapped to map an entity.
Fields
table_name: String
Database table name
canonical_table_alias: String
Calculated alias from table_name
Implementations
sourceimpl TableMapper
impl TableMapper
sourcepub fn new<T>(sql_table_name: &str) -> Self
pub fn new<T>(sql_table_name: &str) -> Self
Create new mapper for table or table alias.
Example: ::new("Book")
or new("Book b")
.
If you use an alias you must map all
SQL columns with the alias too.
sourcepub fn new_with_handler<H>(sql_table_name: &str, handler: H) -> Self where
H: 'static + FieldHandler + Send + Sync,
pub fn new_with_handler<H>(sql_table_name: &str, handler: H) -> Self where
H: 'static + FieldHandler + Send + Sync,
Create a new mapper with a custom handler. Use this to provide custom filter functions for all fields.
sourcepub fn from_mapped<M: Mapped>() -> Result<TableMapper>
pub fn from_mapped<M: Mapped>() -> Result<TableMapper>
Create a new mapper from a struct that implements the Mapped trait.
sourcepub fn from_mapped_with_handler<M: Mapped, H>(handler: H) -> Result<TableMapper> where
H: 'static + FieldHandler + Send + Sync,
pub fn from_mapped_with_handler<M: Mapped, H>(handler: H) -> Result<TableMapper> where
H: 'static + FieldHandler + Send + Sync,
Create a new mapper from a struct that implements the Mapped trait with a custom FieldHandler.
sourcepub fn joined_mapper(&self, path_name: &str) -> Option<String>
pub fn joined_mapper(&self, path_name: &str) -> Option<String>
Returns joined mapper for a path name, if any.
sourcepub fn is_partial_join(&self, path_name: &str) -> bool
pub fn is_partial_join(&self, path_name: &str) -> bool
Returns true, if path name refers to a partial join table.
sourcepub fn merged_mapper(&self, path_name: &str) -> Option<String>
pub fn merged_mapper(&self, path_name: &str) -> Option<String>
Returns joined mapper for a path name, if any.
sourcepub fn map_column<'a, T>(
&'a mut self,
toql_field: &str,
column_name: T
) -> &'a mut Self where
T: Into<String>,
pub fn map_column<'a, T>(
&'a mut self,
toql_field: &str,
column_name: T
) -> &'a mut Self where
T: Into<String>,
Map a column with default FieldOptions
sourcepub fn map_column_with_options<T>(
&mut self,
toql_field: &str,
column_name: T,
options: FieldOptions
) -> &mut Self where
T: Into<String>,
pub fn map_column_with_options<T>(
&mut self,
toql_field: &str,
column_name: T,
options: FieldOptions
) -> &mut Self where
T: Into<String>,
Convenience function for generic TableMapper::map_expr_with_options.
pub fn map_expr_with_options(
&mut self,
toql_field: &str,
expression: SqlExpr,
options: FieldOptions
) -> &mut Self
sourcepub fn map_join(
&mut self,
toql_path: &str,
joined_mapper: &str,
join_type: JoinType,
table_expression: SqlExpr,
on_expression: SqlExpr
) -> &mut Self
pub fn map_join(
&mut self,
toql_path: &str,
joined_mapper: &str,
join_type: JoinType,
table_expression: SqlExpr,
on_expression: SqlExpr
) -> &mut Self
Map a join with default JoinOptions
sourcepub fn map_join_with_options(
&mut self,
toql_path: &str,
joined_mapper: &str,
join_type: JoinType,
table_expression: SqlExpr,
on_expression: SqlExpr,
options: JoinOptions
) -> &mut Self
pub fn map_join_with_options(
&mut self,
toql_path: &str,
joined_mapper: &str,
join_type: JoinType,
table_expression: SqlExpr,
on_expression: SqlExpr,
options: JoinOptions
) -> &mut Self
Map a join with options.
sourcepub fn map_merge(
&mut self,
toql_path: &str,
merged_mapper: &str,
merge_join: SqlExpr,
merge_predicate: SqlExpr
) -> &mut Self
pub fn map_merge(
&mut self,
toql_path: &str,
merged_mapper: &str,
merge_join: SqlExpr,
merge_predicate: SqlExpr
) -> &mut Self
Map a merge with default MergeOptions.
sourcepub fn map_merge_with_options(
&mut self,
toql_path: &str,
merged_mapper: &str,
merge_join: SqlExpr,
merge_predicate: SqlExpr,
options: MergeOptions
) -> &mut Self
pub fn map_merge_with_options(
&mut self,
toql_path: &str,
merged_mapper: &str,
merge_join: SqlExpr,
merge_predicate: SqlExpr,
options: MergeOptions
) -> &mut Self
Map a merge with default MergeOptions.
sourcepub fn map_predicate(&mut self, name: &str, sql_expression: SqlExpr)
pub fn map_predicate(&mut self, name: &str, sql_expression: SqlExpr)
Map a predicate expression with default PredicateOptions.
sourcepub fn map_predicate_with_options(
&mut self,
name: &str,
sql_expression: SqlExpr,
options: PredicateOptions
)
pub fn map_predicate_with_options(
&mut self,
name: &str,
sql_expression: SqlExpr,
options: PredicateOptions
)
Map a predicate expression.
sourcepub fn map_selection(&mut self, name: &str, fields_or_paths: Vec<String>)
pub fn map_selection(&mut self, name: &str, fields_or_paths: Vec<String>)
Map a selection.
sourcepub fn restrict_delete(&mut self, role_expr: RoleExpr)
pub fn restrict_delete(&mut self, role_expr: RoleExpr)
Restrict deleted this struct
with a role expression.
sourcepub fn restrict_load(&mut self, role_expr: RoleExpr)
pub fn restrict_load(&mut self, role_expr: RoleExpr)
Restrict loading this struct
with a role expression.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for TableMapper
impl Send for TableMapper
impl Sync for TableMapper
impl Unpin for TableMapper
impl !UnwindSafe for TableMapper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more