pub struct NamespacedSqlConnection<C: SqlConnection> { /* private fields */ }Expand description
A wrapper around any SqlConnection that prefixes table names with
namespace:database: to provide storage-level isolation between tenants.
§Key Isolation
All storage keys are prefixed: ns:db:table/row_id instead of table/row_id.
This prevents any cross-namespace data leakage at the storage layer.
§Example
// Without namespace prefix:
table key = "users/1"
// With namespace prefix (namespace="prod", database="app"):
table key = "prod:app:users/1"Implementations§
Source§impl<C: SqlConnection> NamespacedSqlConnection<C>
impl<C: SqlConnection> NamespacedSqlConnection<C>
Trait Implementations§
Source§impl<C: SqlConnection> SqlConnection for NamespacedSqlConnection<C>
impl<C: SqlConnection> SqlConnection for NamespacedSqlConnection<C>
Source§fn select(
&self,
table: &str,
columns: &[String],
where_clause: Option<&Expr>,
order_by: &[OrderByItem],
limit: Option<usize>,
offset: Option<usize>,
params: &[CoreSochValue],
) -> SqlResult<ExecutionResult>
fn select( &self, table: &str, columns: &[String], where_clause: Option<&Expr>, order_by: &[OrderByItem], limit: Option<usize>, offset: Option<usize>, params: &[CoreSochValue], ) -> SqlResult<ExecutionResult>
Execute a SELECT query
Source§fn insert(
&mut self,
table: &str,
columns: Option<&[String]>,
rows: &[Vec<Expr>],
on_conflict: Option<&OnConflict>,
params: &[CoreSochValue],
) -> SqlResult<ExecutionResult>
fn insert( &mut self, table: &str, columns: Option<&[String]>, rows: &[Vec<Expr>], on_conflict: Option<&OnConflict>, params: &[CoreSochValue], ) -> SqlResult<ExecutionResult>
Execute an INSERT
Source§fn update(
&mut self,
table: &str,
assignments: &[Assignment],
where_clause: Option<&Expr>,
params: &[CoreSochValue],
) -> SqlResult<ExecutionResult>
fn update( &mut self, table: &str, assignments: &[Assignment], where_clause: Option<&Expr>, params: &[CoreSochValue], ) -> SqlResult<ExecutionResult>
Execute an UPDATE
Source§fn delete(
&mut self,
table: &str,
where_clause: Option<&Expr>,
params: &[CoreSochValue],
) -> SqlResult<ExecutionResult>
fn delete( &mut self, table: &str, where_clause: Option<&Expr>, params: &[CoreSochValue], ) -> SqlResult<ExecutionResult>
Execute a DELETE
Source§fn create_table(&mut self, stmt: &CreateTableStmt) -> SqlResult<ExecutionResult>
fn create_table(&mut self, stmt: &CreateTableStmt) -> SqlResult<ExecutionResult>
Create a table
Source§fn drop_table(&mut self, stmt: &DropTableStmt) -> SqlResult<ExecutionResult>
fn drop_table(&mut self, stmt: &DropTableStmt) -> SqlResult<ExecutionResult>
Drop a table
Source§fn create_index(&mut self, stmt: &CreateIndexStmt) -> SqlResult<ExecutionResult>
fn create_index(&mut self, stmt: &CreateIndexStmt) -> SqlResult<ExecutionResult>
Create an index
Source§fn drop_index(&mut self, stmt: &DropIndexStmt) -> SqlResult<ExecutionResult>
fn drop_index(&mut self, stmt: &DropIndexStmt) -> SqlResult<ExecutionResult>
Drop an index
Source§fn alter_table(&mut self, stmt: &AlterTableStmt) -> SqlResult<ExecutionResult>
fn alter_table(&mut self, stmt: &AlterTableStmt) -> SqlResult<ExecutionResult>
Alter a table (add/drop/rename columns, rename table)
Source§fn commit(&mut self) -> SqlResult<ExecutionResult>
fn commit(&mut self) -> SqlResult<ExecutionResult>
Commit transaction
Source§fn rollback(&mut self, savepoint: Option<&str>) -> SqlResult<ExecutionResult>
fn rollback(&mut self, savepoint: Option<&str>) -> SqlResult<ExecutionResult>
Rollback transaction
Source§fn scan_all(
&self,
table: &str,
columns: &[String],
) -> SqlResult<Vec<HashMap<String, CoreSochValue>>>
fn scan_all( &self, table: &str, columns: &[String], ) -> SqlResult<Vec<HashMap<String, CoreSochValue>>>
Scan all rows from a table (no filter, no ordering).
Used for JOIN processing — each leaf table is scanned once,
then join logic is applied in-memory.
Source§fn eval_join_predicate(
&self,
expr: &Expr,
row: &HashMap<String, CoreSochValue>,
params: &[CoreSochValue],
) -> Option<bool>
fn eval_join_predicate( &self, expr: &Expr, row: &HashMap<String, CoreSochValue>, params: &[CoreSochValue], ) -> Option<bool>
Evaluate an expression against a merged row (used for JOIN ON conditions).
Returns true/false, or None if evaluation fails.
Auto Trait Implementations§
impl<C> Freeze for NamespacedSqlConnection<C>where
C: Freeze,
impl<C> RefUnwindSafe for NamespacedSqlConnection<C>where
C: RefUnwindSafe,
impl<C> Send for NamespacedSqlConnection<C>where
C: Send,
impl<C> Sync for NamespacedSqlConnection<C>where
C: Sync,
impl<C> Unpin for NamespacedSqlConnection<C>where
C: Unpin,
impl<C> UnsafeUnpin for NamespacedSqlConnection<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for NamespacedSqlConnection<C>where
C: UnwindSafe,
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
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>
Converts
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>
Converts
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