1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-07 06:14:03 +00:00
tenancy/src/Database/Concerns
lukinovec ab2a4d8438
Fix chaining withoutPending() with where() (#1457)
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.
2026-04-22 14:32:53 +02:00
..
BelongsToPrimaryModel.php [4.x] Laravel 13 support (#1443) 2026-03-18 19:17:28 +01:00
BelongsToTenant.php [4.x] Laravel 13 support (#1443) 2026-03-18 19:17:28 +01:00
CentralConnection.php Apply fixes from StyleCI 2020-05-22 09:01:31 +00:00
ConvertsDomainsToLowercase.php get phpstan errors down from 252 to 189 2022-08-30 05:44:23 +02:00
CreatesDatabaseUsers.php [4.x] Cleanup (#1317) 2025-02-20 20:49:09 +01:00
EnsuresDomainIsNotOccupied.php get phpstan errors down from 252 to 189 2022-08-30 05:44:23 +02:00
FillsCurrentTenant.php Postgres RLS + permission controlled database managers (#33) 2024-04-24 22:32:49 +02:00
GeneratesIds.php get phpstan errors down from 252 to 189 2022-08-30 05:44:23 +02:00
HasDatabase.php Refactor DatabaseConfig, minor DB manager improvements, resolve todos 2025-10-13 16:01:34 +02:00
HasDomains.php [4.x] Add more relation type annotations (#1424) 2025-12-28 23:20:05 +01:00
HasInternalKeys.php Simplify TenantWithDatabase interface, move tenantConfig() logic 2024-03-01 10:48:33 +01:00
HasPending.php Pending tenants: Add getPendingAttributes() 2025-10-28 12:50:13 +01:00
HasScopedValidationRules.php Fix #998, properly replace ALL tenant_id literals 2022-11-10 16:44:52 +01:00
InitializationHelpers.php Fix code style (php-cs-fixer) 2022-09-29 00:47:38 +00:00
InvalidatesResolverCache.php [4.x] Invalidate resolver cache on delete (#1329) 2025-03-13 17:03:49 +01:00
InvalidatesTenantsResolverCache.php [4.x] Invalidate resolver cache on delete (#1329) 2025-03-13 17:03:49 +01:00
MaintenanceMode.php Fix code style (php-cs-fixer) 2022-10-17 17:48:49 +00:00
ManagesPostgresUsers.php phpstan fixes 2025-01-05 15:50:30 +01:00
PendingScope.php Fix chaining withoutPending() with where() (#1457) 2026-04-22 14:32:53 +02:00
RLSModel.php Postgres RLS + permission controlled database managers (#33) 2024-04-24 22:32:49 +02:00
TenantConnection.php Apply fixes from StyleCI 2020-05-22 09:01:31 +00:00
TenantRun.php phpstan fixes 2025-01-05 15:50:30 +01:00