From ec792cd9c654ead98385de05339fbc97bb32526d Mon Sep 17 00:00:00 2001 From: Justin van Elst Date: Thu, 9 Jan 2025 10:54:17 +0100 Subject: [PATCH] chore formatting --- src/Commands/CreateUserWithRLSPolicies.php | 10 +++++----- src/RLS/PolicyManagers/TableRLSManager.php | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Commands/CreateUserWithRLSPolicies.php b/src/Commands/CreateUserWithRLSPolicies.php index 551a1668..f403ed94 100644 --- a/src/Commands/CreateUserWithRLSPolicies.php +++ b/src/Commands/CreateUserWithRLSPolicies.php @@ -108,9 +108,9 @@ class CreateUserWithRLSPolicies extends Command foreach ($rlsQueries as $table => $queries) { foreach ($queries as $type => $query) { [$hash, $policyQuery] = $this->hashPolicy($query); - $expectedName = $table .'_'.$type.'_rls_policy_' . $hash; + $expectedName = $table . '_' . $type . '_rls_policy_' . $hash; - $tableRLSPolicy = $this->findTableRLSPolicy($table,$type); + $tableRLSPolicy = $this->findTableRLSPolicy($table, $type); $olderPolicyExists = $tableRLSPolicy && $tableRLSPolicy->policyname !== $expectedName; // Drop the policy if an outdated version exists @@ -124,7 +124,7 @@ class CreateUserWithRLSPolicies extends Command } // Create RLS policy if the table doesn't have it or if the --force option is used - $createPolicy = $dropPolicy || ! $tableRLSPolicy || $this->option('force'); + $createPolicy = $dropPolicy || !$tableRLSPolicy || $this->option('force'); if ($createPolicy) { DB::statement($policyQuery); @@ -138,7 +138,7 @@ class CreateUserWithRLSPolicies extends Command } } - if (! empty($createdPolicies)) { + if (!empty($createdPolicies)) { $managerName = str($rlsPolicyManager::class)->afterLast('\\')->toString(); $this->components->info("RLS policies created for tables (using {$managerName}):"); @@ -152,7 +152,7 @@ class CreateUserWithRLSPolicies extends Command } /** @return \stdClass|null */ - protected function findTableRLSPolicy(string $table): object|null + protected function findTableRLSPolicy(string $table, string $type): object|null { return DB::selectOne(<< 0; $i--) { $query .= str_repeat(' ', $i * 4) . ")\n"; - } // closing for CREATE POLICY + } - return $query . ');'; + $query .= ');'; // closing for CREATE POLICY + + return $query; } protected function getComment(string $tableName, string $columnName): string|null