1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 07:34:03 +00:00

Make path skipping logic more explicit

This commit is contained in:
lukinovec 2025-05-21 13:58:16 +02:00
parent 349ac6e9fc
commit adfddab951

View file

@ -142,7 +142,10 @@ class TableRLSManager implements RLSPolicyManager
$pathExplicitlySkipped = $foreignKey['comment'] === 'no-rls';
$pathImplicitlySkipped = ! static::$scopeByDefault && (
! isset($foreignKey['comment']) ||
(is_string($foreignKey['comment']) && ! Str::startsWith($foreignKey['comment'], 'rls'))
(is_string($foreignKey['comment']) && ! (
Str::is($foreignKey['comment'], 'rls') || // Explicit RLS
Str::startsWith($foreignKey['comment'], 'rls ') // Comment constraint
))
);
return $pathExplicitlySkipped || $pathImplicitlySkipped;
@ -169,7 +172,7 @@ class TableRLSManager implements RLSPolicyManager
// Validate comment constraint format
if (count($constraint) !== 2 || empty($constraint[0]) || empty($constraint[1])) {
throw new RLSCommentConstraintException("Incorrectly formatted comment constraint on {$tableName}.{$column['name']}: '{$column['comment']}'");
throw new RLSCommentConstraintException("Malformed comment constraint on {$tableName}.{$column['name']}: '{$column['comment']}'");
}
$foreignTable = $constraint[0];