pub struct Tenant { /* private fields */ }Expand description
Scopes every query, and every joined table, to tenants: column IN (?, ...)
(in a left or right join’s ON, elsewhere in the WHERE).
PHP: Utopia\Query\Hook\Filter\Tenant.
use utopia_query::builder::MySql;
use utopia_query::hook::Tenant;
let statement = MySql::new().from("docs", "").add_hook(Tenant::new(["7"], "tenant_id")?)?.build()?;
assert_eq!(statement.query, "SELECT * FROM `docs` WHERE tenant_id IN (?)");use Utopia\Query\Builder\MySQL;
use Utopia\Query\Hook\Filter\Tenant;
echo (new MySQL())->from('docs')->addHook(new Tenant(['7']))->build()->query, "\n"; // SELECT * FROM `docs` WHERE tenant_id IN (?)Implementations§
Trait Implementations§
Source§impl JoinFilter for Tenant
impl JoinFilter for Tenant
Source§fn filter_join(
&self,
table: &str,
join_type: JoinType,
) -> Result<Option<JoinCondition>>
fn filter_join( &self, table: &str, join_type: JoinType, ) -> Result<Option<JoinCondition>>
The same condition: in the ON of left and right joins (so unmatched
rows survive), in the WHERE otherwise.
impl StructuralPartialEq for Tenant
Auto Trait Implementations§
impl Forget for Tenant
impl Freeze for Tenant
impl Move for Tenant
impl RefUnwindSafe for Tenantwhere
Atomic<*mut ()>: RefUnwindSafe,
Atomic<usize>: RefUnwindSafe,
OnceLock<Index>: RefUnwindSafe,
Atomic<u8>: RefUnwindSafe,
impl Send for Tenant
impl Sync for Tenant
impl Unpin for Tenant
impl UnsafeUnpin for Tenantwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Value<Object>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for Tenantwhere
RawVecInner: UnwindSafe,
&'static [u8]: UnwindSafe,
*const u8: UnwindSafe,
Align8<*mut ()>: UnwindSafe,
&'static Vtable: UnwindSafe,
Arc<Repr<Object>>: UnwindSafe,
BoxRaw<Query>: 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