mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-07 06:14:03 +00:00
At the moment, `where()` cannot be used correctly while using
`withoutPending()`. For example, if we have a single non-pending tenant
in our DB (with ID 'foo'), queries like
`Tenant::withoutPending()->where('id', 'nonexistent')->first()`will
incorrectly return the non-pending tenant ('foo').
This is because `withoutPending()` does
`$builder->whereNull('data->pending_since')->orWhereNull('data')`. These
two aren't grouped, so `withoutPending()->where('id', 'nonexistent')`
basically translates to "WHERE data->pending_since IS NULL **OR (data IS
NULL AND id = 'nonexistent')**". So the query will include all tenants
whose `pending_since` is null (= all non-pending tenants).
Grouping `->whereNull('data->pending_since')->orWhereNull('data')` in a
closure passed to a separate `where()` fixes this issue.
|
||
|---|---|---|
| .. | ||
| BelongsToPrimaryModel.php | ||
| BelongsToTenant.php | ||
| CentralConnection.php | ||
| ConvertsDomainsToLowercase.php | ||
| CreatesDatabaseUsers.php | ||
| EnsuresDomainIsNotOccupied.php | ||
| FillsCurrentTenant.php | ||
| GeneratesIds.php | ||
| HasDatabase.php | ||
| HasDomains.php | ||
| HasInternalKeys.php | ||
| HasPending.php | ||
| HasScopedValidationRules.php | ||
| InitializationHelpers.php | ||
| InvalidatesResolverCache.php | ||
| InvalidatesTenantsResolverCache.php | ||
| MaintenanceMode.php | ||
| ManagesPostgresUsers.php | ||
| PendingScope.php | ||
| RLSModel.php | ||
| TenantConnection.php | ||
| TenantRun.php | ||