pub struct GenericSQLVirtualServerModel(/* private fields */);Expand description
A stateless SQL query builder virtual server operations.
This struct generates SQL query strings without executing them, allowing the caller to execute the queries against a SQL connection.
Implementations§
Source§impl GenericSQLVirtualServerModel
impl GenericSQLVirtualServerModel
Sourcepub fn new(args: GenericSQLVirtualServerModelArgs) -> Self
pub fn new(args: GenericSQLVirtualServerModelArgs) -> Self
Creates a new GenericSQLVirtualServerModel instance.
Sourcepub fn view_expand(
&self,
view_id: &str,
config: &ViewConfig,
row_index: u32,
) -> GenericSQLResult<String>
pub fn view_expand( &self, view_id: &str, config: &ViewConfig, row_index: u32, ) -> GenericSQLResult<String>
Returns the UPDATE showing the children of the row_index-th visible
row, each collapsed, whose affected-row count is the rows shown.
§Returns
SQL: UPDATE {view_id} SET "__HIDDEN__" = FALSE FROM (...) AS r WHERE ...
Sourcepub fn view_collapse(
&self,
view_id: &str,
config: &ViewConfig,
row_index: u32,
) -> GenericSQLResult<String>
pub fn view_collapse( &self, view_id: &str, config: &ViewConfig, row_index: u32, ) -> GenericSQLResult<String>
Returns the UPDATE hiding every descendant of the row_index-th
visible row, whose affected-row count is the rows hidden.
§Returns
SQL: UPDATE {view_id} SET "__HIDDEN__" = TRUE FROM (...) AS r WHERE ...
Sourcepub fn view_set_depth(
&self,
view_id: &str,
config: &ViewConfig,
depth: u32,
) -> GenericSQLResult<String>
pub fn view_set_depth( &self, view_id: &str, config: &ViewConfig, depth: u32, ) -> GenericSQLResult<String>
Returns the UPDATE expanding exactly the rows whose path is no longer
than depth.
§Returns
SQL: UPDATE {view_id} SET "__HIDDEN__" = ({depth expr} > {depth + 1})
Sourcepub fn table_path(&self, parts: &[&str]) -> GenericSQLResult<String>
pub fn table_path(&self, parts: &[&str]) -> GenericSQLResult<String>
Renders a hosted table’s relation path - e.g. ["memory", "main", "trades"] - as its entity id: parts joined with ., each quoted
only when it is not a bare identifier, so that SQL-safe names read as
they always have (memory.trades) and every other name is still a
relation reference the builder passes through verbatim.
Sourcepub fn quote_entity(&self, entity_id: &str) -> GenericSQLResult<String>
pub fn quote_entity(&self, entity_id: &str) -> GenericSQLResult<String>
Returns the SQL relation reference for an entity id - a hosted table’s path verbatim, any other name quoted whole - for handlers that build their own queries against an entity.
Sourcepub fn get_hosted_tables(&self) -> GenericSQLResult<String>
pub fn get_hosted_tables(&self) -> GenericSQLResult<String>
Sourcepub fn table_schema(&self, table_id: &str) -> GenericSQLResult<String>
pub fn table_schema(&self, table_id: &str) -> GenericSQLResult<String>
Sourcepub fn table_size(&self, table_id: &str) -> GenericSQLResult<String>
pub fn table_size(&self, table_id: &str) -> GenericSQLResult<String>
Sourcepub fn view_column_size(&self, view_id: &str) -> GenericSQLResult<String>
pub fn view_column_size(&self, view_id: &str) -> GenericSQLResult<String>
Sourcepub fn expressions_describe(
&self,
table_id: &str,
config: &ViewConfig,
) -> GenericSQLResult<Option<String>>
pub fn expressions_describe( &self, table_id: &str, config: &ViewConfig, ) -> GenericSQLResult<Option<String>>
Returns the SQL query that plans every expression of config at once
against table_id.
§Returns
SQL: DESCRIBE (SELECT {expr} AS "{alias}", ... FROM {table_id})
Sourcepub fn expression_describe(
&self,
table_id: &str,
expression: &str,
) -> GenericSQLResult<String>
pub fn expression_describe( &self, table_id: &str, expression: &str, ) -> GenericSQLResult<String>
Returns the SQL query that plans one expression against a table.
§Returns
SQL: DESCRIBE (SELECT {expression} FROM {table_id})
Sourcepub fn table_describe(
&self,
table_id: &str,
config: &ViewConfig,
schema: &IndexMap<String, ColumnType>,
) -> GenericSQLResult<Option<String>>
pub fn table_describe( &self, table_id: &str, config: &ViewConfig, schema: &IndexMap<String, ColumnType>, ) -> GenericSQLResult<Option<String>>
Returns the SQL query that plans the view config would build against
table_id, without materializing it.
§Returns
SQL: DESCRIBE (SELECT ... GROUP BY ...)
Sourcepub fn table_describe_unordered(
&self,
table_id: &str,
config: &ViewConfig,
schema: &IndexMap<String, ColumnType>,
) -> GenericSQLResult<Option<String>>
pub fn table_describe_unordered( &self, table_id: &str, config: &ViewConfig, schema: &IndexMap<String, ColumnType>, ) -> GenericSQLResult<Option<String>>
As Self::table_describe, for a source with no natural row order -
a table made by Self::view_make_table in a dialect whose
create_entity is a view, which row_id_expr cannot address.
Sourcepub fn view_delete(&self, view_id: &str) -> GenericSQLResult<String>
pub fn view_delete(&self, view_id: &str) -> GenericSQLResult<String>
Sourcepub fn table_make_view(
&self,
table_id: &str,
view_id: &str,
config: &ViewConfig,
schema: &IndexMap<String, ColumnType>,
) -> GenericSQLResult<String>
pub fn table_make_view( &self, table_id: &str, view_id: &str, config: &ViewConfig, schema: &IndexMap<String, ColumnType>, ) -> GenericSQLResult<String>
Returns the SQL query to create a view from a table with the given configuration.
§Arguments
table_id- The identifier of the source table.view_id- The identifier for the new view.config- The view configuration specifying columns, group_by, split_by, etc.schema- The schema of the source table (column names to types).
§Returns
SQL: CREATE TABLE {view_id} AS (...)
Sourcepub fn table_make_view_unordered(
&self,
table_id: &str,
view_id: &str,
config: &ViewConfig,
schema: &IndexMap<String, ColumnType>,
) -> GenericSQLResult<String>
pub fn table_make_view_unordered( &self, table_id: &str, view_id: &str, config: &ViewConfig, schema: &IndexMap<String, ColumnType>, ) -> GenericSQLResult<String>
As Self::table_make_view, for a source with no natural row order -
a table made by Self::view_make_table in a dialect whose
create_entity is a view, which row_id_expr cannot address - so an
unsorted view takes the source’s own order and windows never read
row_id_expr.
Sourcepub fn view_make_table(
&self,
view_id: &str,
table_id: &str,
config: &ViewConfig,
view_schema: &IndexMap<String, ColumnType>,
schema: Option<&IndexMap<String, ColumnType>>,
) -> GenericSQLResult<String>
pub fn view_make_table( &self, view_id: &str, table_id: &str, config: &ViewConfig, view_schema: &IndexMap<String, ColumnType>, schema: Option<&IndexMap<String, ColumnType>>, ) -> GenericSQLResult<String>
Returns the SQL query to create a table from a view, with the view’s
row path unrolled into key columns named after their group_by
columns and aggregates of those columns qualified by their aggregate.
§Arguments
view_id- The identifier of the source view.table_id- The identifier for the new table.config- The configuration the view was created with.view_schema- The schema of the view’s relation.schema- The columns of the new table, in place of the view’s.
§Returns
SQL: CREATE TABLE {table_id} AS (SELECT ... FROM {view_id})
Sourcepub fn view_get_data(
&self,
view_id: &str,
config: &ViewConfig,
viewport: &ViewPort,
schema: &IndexMap<String, ColumnType>,
) -> GenericSQLResult<String>
pub fn view_get_data( &self, view_id: &str, config: &ViewConfig, viewport: &ViewPort, schema: &IndexMap<String, ColumnType>, ) -> GenericSQLResult<String>
Returns the SQL query to fetch data from a view with the given viewport.
§Arguments
view_id- The identifier of the view.config- The view configuration.viewport- The viewport specifying row/column ranges.schema- The schema of the view (column names to types).
§Returns
SQL: SELECT ... FROM {view_id} LIMIT ... OFFSET ...
Sourcepub fn view_schema(&self, view_id: &str) -> GenericSQLResult<String>
pub fn view_schema(&self, view_id: &str) -> GenericSQLResult<String>
Sourcepub fn view_size(&self, view_id: &str) -> GenericSQLResult<String>
pub fn view_size(&self, view_id: &str) -> GenericSQLResult<String>
Sourcepub fn view_get_min_max(
&self,
view_id: &str,
column_name: &str,
config: &ViewConfig,
) -> GenericSQLResult<String>
pub fn view_get_min_max( &self, view_id: &str, column_name: &str, config: &ViewConfig, ) -> GenericSQLResult<String>
Returns the SQL query to get the min and max values of a column.
§Arguments
view_id- The identifier of the view.column_name- The name of the column.config- The view configuration.
§Returns
SQL: SELECT MIN("column_name"), MAX("column_name") FROM {view_id}
When the view uses ROLLUP grouping (non-flat mode with group_by),
a WHERE __GROUPING_ID__ = 0 clause is added to exclude non-leaf rows.
Trait Implementations§
Source§impl Clone for GenericSQLVirtualServerModel
impl Clone for GenericSQLVirtualServerModel
Source§impl Debug for GenericSQLVirtualServerModel
impl Debug for GenericSQLVirtualServerModel
Auto Trait Implementations§
impl Forget for GenericSQLVirtualServerModel
impl Freeze for GenericSQLVirtualServerModel
impl RefUnwindSafe for GenericSQLVirtualServerModel
impl Send for GenericSQLVirtualServerModel
impl Sync for GenericSQLVirtualServerModel
impl Unpin for GenericSQLVirtualServerModel
impl UnsafeUnpin for GenericSQLVirtualServerModel
impl UnwindSafe for GenericSQLVirtualServerModel
Blanket Implementations§
impl<T> Allocation for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more